Jump to content

Mailto and Add to table??


danposs86

Recommended Posts

Is it possible to have a form (contact form, will ask for name, email address, phone number, enquiry and a tick box) that will save certain items (name, email, number and whether the box was ticked or not) to a table on a mysql database while also emailing all of the items to an email address??

Link to comment
Share on other sites

Of course it is, saving something in a database or sending an email doesn't magically make that data unavailable for other use. You can have the calls to mysql_query and mail on consecutive lines if you really want to.

Link to comment
Share on other sites

I have the layout for my form.

<form name="form1" method="post" action="">			  <table width="440" border="0" cellspacing="1" cellpadding="1">				<tr>				  <td width="140">Full Name: </td>				  <td><input name="form_name" type="text" size="40"></td>				</tr>				<tr>				  <td>Email Address: </td>				  <td><input name="form_email" type="text" size="40"></td>				</tr>				<tr>				  <td>Phone Number: </td>				  <td><input name="form_number" type="text" size="40"></td>				</tr>				<tr>				  <td>Enquiry:</td>				  <td><textarea name="form_enquiry" cols="30" rows="5"></textarea></td>				</tr>				<tr>				  <td colspan="2">Newsletter/updates 				  <input type="checkbox" name="checkbox" value="checkbox"></td>				</tr>				<tr>				  <td> </td>				  <td><input type="submit" name="Submit" value="Submit"></td>				</tr>			  </table>			</form>

I have the database settings already on the PHP page.I am having an off-day, not really a clue where to start.Been thinking about it and there are 3 fields i want set as required, Name, Email and the Enquiry itself. I want everything to be sent to an email address (for now it's 'info@something.co.uk').But, the check box, i want something where, if it is ticked it will also save the Name, Email and Phone Number to a table on a MySQL forum while also sending everything to the email address.I have no idea where to start with the coding, can anyone point me in the right direction, or some code from a tutorial that may help me. Thanks.

Link to comment
Share on other sites

This is the description of form handling:http://www.w3schools.com/php/php_forms.aspI prefer to use a hidden input to tell the form handler what to do.<input type="hidden" name="page_mode" value="submit" />

if ($_POST['page_mode'] == "submit"){  //the form was submitted}

Once you know whether or not it was submitted, you can get the information from $_POST and validate it or make sure it's not empty, show an error message if it is, or else send the email. You can check if the checkbox was selected and add it to the database.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...