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 = "reggie@shadowmarket.com";



$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.

Link to comment
Share on other sites

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 = "reggie@shadowmarket.com";
$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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.