...

View Full Version : Creating a page to do a couple of things



kma07
06-17-2010, 01:22 AM
HI guys, I'm quite a novice when it comes to this but was wondering how do I create a simple page to :

Enter a filename
Enter an email address

Submit

When submit is pressed, I have a program to convert the file and then send it to the email entered.

I've got the html designed but I'm not sure how to get the submit part started

optimus203
06-17-2010, 01:49 AM
You need a form and a server side scripting language to pass the information. I prefer PHP. Here are a few links that will help you get started:

http://email.about.com/od/emailprogrammingtips/qt/How_to_Send_Email_from_a_PHP_Script.htm

http://www.ibdhost.com/contact/

kma07
06-17-2010, 02:44 AM
Thanks!

I think I got the email part right

Now,

How do I take the filename that is entered (assuming its on c:\<filename>) and run my program that converts it and then send it to the email address entered?

optimus203
06-17-2010, 03:02 AM
This is a server-side script. You cannot test it locally. You have to:

1 - set the proper link to the php script in your form
<form method="post" action="filename.php">

2 - upload the php script to your server in the right directory (as specified in the link above)

3 - test the script out to make sure it works.

You should check with your service provider to make sure they support PHP. Most do nowadays, but not all.

kma07
06-17-2010, 03:15 AM
I uploaded the script to the server and I don't think it works...
it just gives me a blank page after I enter the details

optimus203
06-17-2010, 03:16 AM
post your html form code and php code so we can troubleshoot.

kma07
06-17-2010, 03:21 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<title> CSV to XML Conversion </title>
<link rel="stylesheet" href="/ssi/subs.css" type="text/css" />
</head>

<body>

<a name="top"></a>
<!-- start top nav -->
<div id="nav">
</div>

<div id="main">

<div class="subsbox">
<form action="csv_to_xml.php" method="get" name="input">
<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>
<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />

<table border="0">
<tr>
<td class="sm"><label class="subs_label" for="csvfileName">FILENAME(no extension):</label></td>
<td class="sm"><input class="nice" type="text" name="csvfilename" id="filename"></td>
</tr>
<tr>
<td class="sm"><label class="subs_label" for="email">EMAIL:</label></td>
<td class="sm"><input class="nice" type="text" name="email" id="your@email.com"></td>
</tr>
<tr>
<td class="sm" colspan="2" align="right"><input type="Submit" src="C:\Documents and Settings\Mak\My Documents\My Pictures/goimage.jpg" value="Convert">

</td>
</tr>
</table>
</form>
</div>


</body>
</html>

kma07
06-17-2010, 03:22 AM
<?php
$email = "recipient@example.com";
$subject = "$csvfilename";

if (mail($email, $subject,)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}

<?

optimus203
06-17-2010, 03:26 AM
Don't know if this was a typo, but the <? part at end should be reversed:

<?php
$email = "recipient@example.com";
$subject = "$csvfilename";

if (mail($email, $subject,)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}

?>

kma07
06-17-2010, 03:38 AM
Ok I fixed that but it still gives me a blank page

optimus203
06-17-2010, 03:48 AM
Hmnn. PHP is not my area of expertise. Try posting in the PHP forum on this site. I'm sure someone will be able to help you there. Sorry and good luck.

kma07
06-17-2010, 03:50 AM
Cheers anyway

much appreciated



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum