PHP forms are actually pretty simple. You'll only need two files: one php file (doesn't have to be, but preferred personally) for the form, and a php file to process the information and send the e-mail.
In your first *.php or *.html file, you'll write the form in html, obviously.
HTML Code:
<form method="post" action="urlscript.php">
<span>Your Name</span>: <input type="text" name="realname" size="30" maxlength="50" /><br />
<span>Your E-Mail</span>: <input type="text" name="useremail" size="30" maxlength="100" /><br />
<span>Your Celebrity Entries:</span>:<br />
<textarea name="entries" rows="20" cols="40">
</textarea><br />
<input type="submit" name="submit" value="submit" />
</form>
'action="urlscript.php"' is the location where the information will be processed. Rename it accordingly to that of your file which processes the information.
In the file you inserted in the action attribute, you'll need to process said information, and let the users send an e-mail to yours after clicking submit.
PHP Code:
<?php $realname = $_REQUEST['realname']; $useremail = $_REQUEST['useremail']; $entries = $_REQUEST['entries'];
mail('gakoyu@test.com', 'Celebrity Names - by '.$realname.'', $entries, 'From: '.$useremail); ?>
As you can see, I've assigned variables to the named input types (being "realname", etcetera). These variables can then be used for the mail function.
mail() needs several parameters, and several additional ones can be added too, if wished. In this case, we give the following parameters: the mail to which it needs to be sent, the subject of the e-mail, the message/body, and an additional parameter that shows from who the e-mail comes ($useremail)..
You can also add a header() function to the top of the document, as that will redirect the user to a new page instead of remaining a blank one.
Oh, also make sure you change the e-mail in the PHP code above; it's merely a random email I've used which is not the one you need, obviously.
That's it. 
__________________
$gocore = new gakoyucore();
$con = mysql_connect($gocore->server, $gocore->username, $gocore->password) or die(mysql_error());
Last edited by Gakoyu Ojima; 11-17-2010 at 07:20 AM..
|