Page 1 of 1

form 2 mail

Posted: Sun May 02, 2010 12:45 pm
by gk01
hey guys,
I need to know how to have the details of my registration form go to an email address without having to pass through a db. Im guessing my employers want to selectivley store data info of the registering clients to then offer them other service packages, however, my job is developing the php code behind it together with its requisit documentation. so below is a script for the form being proposed, followed by the script i've attempted to execute...but i keep failing...
can someone please help me out?!! by the way im using CS4...and bare with my lack of knowledge for my php code

Script for form.....and where does tha java script go...and how does it work
<form method="post" name="cio" action="whynot.php">

<table width="100%" border="0" cellspacing="0" cellpadding="4" style="font-family:Arial, Helvetica, sans-serif; font-size:12px;">
<tr>
<td width="124">Surname</td>
<td width="366"><input type="text" name="Surname" id="textfield" /></td>
<td width="119">Other Names</td>
<td width="239"><input type="text" name="Other_Names" id="Other_Names" /></td>
</tr>
<tr>
<td>Designation</td>
<td><input type="text" name="Designation" id="Designation" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Company</td>
<td><input type="text" name="Company" id="Company" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Physical Address</td>
<td><input type="text" name="Physical_Address" id="Physical_Address" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Postal Address</td>
<td><input type="text" name="Postal_Address" id="Postal_Address" /></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Postal Code</td>
<td><input type="text" name="Postal_Code" id="Postal_Code" /></td>
<td>City/Town</td>
<td><input type="text" name="City_Town" id="City_Town" /></td>
</tr>
<tr>
<td>Country</td>
<td><input type="text" name="Country" id="Country" /></td>
<td>Region</td>
<td><input type="text" name="Region" id="Region" /></td>
</tr>
<tr>
<td>Tel(Home):</td>
<td><input type="text" name="Tel_Home" id="Tel_Home" /></td>
<td>Tel(Work):</td>
<td><input type="text" name="Tel_Work" id="Tel_Work" /></td>
</tr>
<tr>
<td>Fax</td>
<td><input type="text" name="Fax" id="Fax" /></td>
<td>CellPhone</td>
<td><input type="text" name="CellPhone" id="CellPhone" /></td>
</tr>
<tr>
<td>Email(Personal):</td>
<td><input type="text" name="Email_Personal" id="Email_Personal" /></td>
<td>Email(Work):</td>
<td><input type="text" name="Email_Work" id="Email_Work" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>

<table width="760" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="395" height="51">&nbsp;</td>
<td width="365"><input type="submit" onClick="return confirm('Send form?');" name="form_submitted_successfully" value="Submit" />
<label>
<input type="reset" name="CANCEL" id="CANCEL">
</label></td>
</tr>
</table>
<p>&nbsp;</p>
</form></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>


my attempted script..

<?php
///so whats wrong...i thought its gonna post all these details in the order i've specified here!!
$Surname = $_POST['Surname'];
$Other_Names = $_POST['Other_Names'];
$Designation = $_POST['Designation'];
$Company = $_POST['Company'];
$Physical_Address = $_POST['Physical_Address'];
$Postal_Address = $_POST['Postal_Address'];
$Postal_Code = $_POST['Postal_Code'];
$City_Town = $_POST['City_Town'];
$Country = $_POST['Country'];
$Region = $_POST['Region'];
$Tel_Home = $_POST['Tel_Home'];
$Tel_Work = $_POST['Tel_Work'];
$Fax = $_POST['Fax'];
$CellPhone = $_POST['CellPhone'];
$Email_Personal = $_POST['Email_Personal'];
$Email_Work = $_POST['Email_Work'];

$email_from = 'kabare.gicharu@cio.co.ke';
$email_subject = "testing breakfast-launch for cio";
$email_body = "you have recived an event registration from $Surname.\n".
"Here are his details:\n $message". //change the way this <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> is presented

$to = "kabare.gicharu@cio.co.ke";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $Personal_Email \r\n";

mail($to,$email_subject,$email_body,$headers);

header('Location: thanks.html');


// Function to validate against any email injection attempts///the <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>
//function IsInjected($str)
//{
// $injections = array('(\n+)',
// '(\r+)',
// '(\t+)',
// '(%0A+)',
// '(%0D+)',
// '(%08+)',
// '(%09+)'
// );
// $inject = join('|', $injections);
// $inject = "/$inject/i";
// if(preg_match($inject,$str))
// {
// return true;
// }
// else
// {
// return false;
// }
//}

?>