Jump to content

send email, and post info to database


webguync

Recommended Posts

well here is the form code

 

<html>
<head>
<title>Shadowmarket.com email form</title>
<link rel="stylesheet" href="form.css" type="text/css" media="screen, handheld" />
</head>
<body>
<form action="formtoemailpro.php" method="post">
<fieldset>
<legend></legend>
<table cellspacing="5">
<tr><td><span class="asterisk">*</span><span class="small"> indicates a required field</td></tr>
<tr><td><span class="asterisk">*</span> First Name:</td><td><input type="text" size="30" name="fname"></td></tr>
<tr><td><span class="asterisk">*</span> Last Name:</td><td><input type="text" size="30" name="lname"></td></tr>
<tr><td><span class="asterisk">*</span> Zip Code:</td><td><input type="text" size="30" name="zip"></td></tr>
<tr><td><span class="asterisk">*</span> Login email:</td><td><input type="text" size="30" name="loginemail"></td></tr>
<tr><td><span class="asterisk">*</span> Login Password:</td><td><input type="password" size="30" name="loginpw"></td></tr>
<tr><td>  Phone:</td><td><input type="text" size="30" name="phone"></td></tr>

<tr><td> </td><td>
<table border="0">
<tr><td colspan="3">Security test.  Please identify the pictures:</td></tr>
<tr><td><img src="images/identiPIC_1.jpg" alt=""></td><td><img src="images/identiPIC_2.jpg" alt=""></td><td><img src="images/identiPIC_3.jpg" alt=""></td></tr>
<tr><td>
<select name="identiPIC_selected[1]">
<option value="">Click to identify</option>
<option>Apple</option>
<option>Cat</option>
<option>Clock</option>
<option>Dog</option>
<option>Flower</option>
<option>Fork</option>
<option>Hammer</option>
<option>Key</option>
<option>Ship</option>
<option>Tree</option>
</select></td><td>

<select name="identiPIC_selected[2]">
<option value="">Click to identify</option>
<option>Apple</option>
<option>Cat</option>
<option>Clock</option>
<option>Dog</option>
<option>Flower</option>
<option>Fork</option>
<option>Hammer</option>
<option>Key</option>
<option>Ship</option>
<option>Tree</option>
</select></td><td>

<select name="identiPIC_selected[3]">
<option value="">Click to identify</option>
<option>Apple</option>
<option>Cat</option>
<option>Clock</option>
<option>Dog</option>
<option>Flower</option>
<option>Fork</option>
<option>Hammer</option>
<option>Key</option>
<option>Ship</option>
<option>Tree</option>
</select></td></tr></table></td></tr>

<tr><td> 

</td><td align="right"><input type="image" src="images/Send.jpg" value="Send"></td></tr>
</table>
</fieldset>
</form>
</body>
</html>

 

and the code to submit the information

 

<?php

//set up database and table names
$db_name ="shadowdata";
$table_name ="RegistrationForm";

//connect to MySQL and select database to use
$connection = @mysql_connect("localhost","username","password") or die(mysql_error());

$db = @mysql_select_db($db_name,$connection) or die(mysql_error());

//create SQL statement and issue query
$sql = "INSERT INTO $table_name (fname, lname, zip, loginemail, loginpw, phone) VALUES ('$_POST[fname]', '$_POST[lname]', '$_POST[zip]', '$_POST[loginemail]', '$_POST[loginpw]', '$_POST[phone]')";

$result = @mysql_query($sql,$connection)or die(mysql_error());
$my_email = "[email protected]";



$bcc = "";


$subject = "Comments from contact form";
?>

 

there is more code that I left out such as checking for required fields, but I thought you could use this to show me what needs to be done.

I'd use this php code:

<?php

//set up database and table names
$db_name ="shadowdata";
$table_name ="RegistrationForm";

//connect to MySQL and select database to use
$connection = @mysql_connect("localhost","username","password") or die(mysql_error());

$db = @mysql_select_db($db_name,$connection) or die(mysql_error());

//create SQL statement and issue query
$sql = "INSERT INTO $table_name (fname, lname, zip, loginemail, loginpw, phone) VALUES ('$_POST[fname]', '$_POST[lname]', '$_POST[zip]', '$_POST[loginemail]', '$_POST[loginpw]', '$_POST[phone]')";

$result = @mysql_query($sql,$connection)or die(mysql_error());

/* E-mail stuff here */
$my_email = "[email protected]";
$bcc = "";
$subject = "Comments from contact form";
$message = "You received a mesage from {$_POST['loginemail']}"; //populate as you see fit from data from the form
mail($my_email, $subject, $message);
?>

or something like it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.