File: /home/nyiet8349bzl/Backup/sbc_back/homedir/public_html/test/form1.php
<form name="contactform" method="post" action="form1.php">
<table width="600px">
<tr>
<td valign="top">
<label for="name">Name </label>
</td>
<td valign="top">
<input type="text" name="name" maxlength="50" size="30" required>
</td>
</tr>
<tr>
<td valign="top">
<label for="Affiliation"> Affiliation </label>
</td>
<td valign="top">
<input type="text" name="Affiliation" maxlength="30" size="30" required>
</td>
</tr>
<tr>
<td valign="top">
<label for="Designation">Designation </label>
</td>
<td valign="top">
<input type="text" name="Designation" maxlength="30" size="30" required>
</td>
</tr>
<tr>
<td valign="top"">
<label for="address" > Correspondence Address</label>
</td>
<td valign="top">
<textarea type="text" name="address" maxlength="50" size="30" required>
</textarea>
</td>
</tr>
<tr>
<tr>
<td valign="top">
<label for="telephone">Telephone/ Mobile</label>
</td>
<td valign="top">
<input type="text" name="telephone" maxlength="10" size="30" required>
</td>
</tr>
<tr>
<tr>
<td valign="top">
<label for="email">Email ID </label>
</td>
<td valign="top">
<input type="text" name="email" maxlength="80" size="30" required>
</td>
</tr>
<tr>
<td>
Registration Type
<td> <select name="Regtype">
<option value="Indian Participants">Indian Participants</option>
<option value="Institutional/Corporate Delegates">Institutional/Corporate Delegates </option>
<option value="Research Scholars and Participants from DU">Research Scholars and Participants from DU</option>
<option value="Foreign Delegates">Foreign Delegates</option>
</select>
</td>
</tr>
<tr><td>Presenting Paper</td>
<td><input type="radio" name="paper" value="Yes">Yes</input>
<input type="radio" name="paper" value="No">No</input></td>
</tr>
</tr>
<tr>
<td>
Theme for Research Paper:
<td> <select name="themeforResearch" value = "themeforResearch">
<option value="Smart Cities and Urban Infrastructure">Smart Cities and Urban Infrastructure</option>
<option value="Urban Environment and Micro-climate Change">Urban Environment and Micro-climate Change</option>
<option value="Urban Housing and Slums">Urban Housing and Slums</option>
<option value="Disaster Risk Reduction and Urban Sustainable Planning">Disaster Risk Reduction and Urban Sustainable Planning</option>
<option value="Mega Cities: Problems and Prospects">Mega Cities: Problems and Prospects</option>
<option value="Marginalized Spaces in Urban System">Marginalized Spaces in Urban System</option>
<option value="Urban Governance and Policies">Urban Governance and Policies</option>
<option value="Urban Health and Well-being">Urban Health and Well-being</option>
<option value="Human Health and Well-being">Human Health and Well-being</option>
<option value="Geospatial Techniques and Urban Planning">Geospatial Techniques and Urban Planning</option>
<option value="Sustainable Urban Economy">Sustainable Urban Economy</option>
</select>
</td>
<tr><td>Abstract</td>
<td><textarea name ="Abstract" size = "30"></textarea></td></tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="submit" value="Submit" name="cc">
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['email']))
{
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "jitendra@bagwarsoftwares.com";
$email_subject = "Enquiry";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
//echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
//echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['address']) ||
!isset($_POST['Designation']) ||
!isset($_POST['Affiliation']) ||
!isset($_POST['email']) ||
!isset($_POST['telephone'])||
!isset($_POST['Regtype'])||
!isset($_POST['themeforResearch'])||
!isset($_POST['Abstract']))
{
died('\nWe are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = isset($_POST['name']); // required
$Affiliation = isset($_POST['Affiliation']); // required
$Designation = isset($_POST['Designation']); // required
$address = isset($_POST['address']); // required
$email_from = isset($_POST['email']); // required
$telephone = isset($_POST['telephone']); // not required
$Regtype = isset($_POST['Regtype']); // required
$ppa = isset($_POST['paper']); // required
$themeforResearch = isset($_POST['themeforResearch']); //required
$Abstract = isset($_POST['Abstract']); //required
/* $error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$address)) {
$error_message .= 'The Address you entered does not appear to be valid.<br />';
}
if($Regtype == '') {
$error_message .= 'You did not Select Your Registration Type:.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}*/
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name : ".clean_string($_POST['name'])."\n";
$email_message .= "Address : ".clean_string($_POST['address'])."\n";
$email_message .= "Affiliation : ".clean_string($_POST['Affiliation'])."\n";
$email_message .= "Designation : ".clean_string($_POST['Designation'])."\n";
$email_message .= "Mobile : ".clean_string($_POST['telephone'])."\n";
$email_message .= "Email : ".clean_string($_POST['email'])."\n";
$email_message .= "Registration Type : ".clean_string($_POST['Regtype'])."\n";
$email_message .= "Presenting Paper : ".clean_string($_POST['paper'])."\n";
$email_message .= "Theme For Research Paper: ".clean_string($_POST['themeforResearch'])."\n";
$email_message .= "Abstract : ".clean_string($_POST['Abstract'])."\n";
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$con = mysql_connect("localhost","sbsc_register","sbsc@123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("sbsc_register", $con);
$sql = "INSERT INTO `college`(`name`, `address`, `affiliation`, `Designation`, `Mobile`, `email`, `Registype`, `prespapr`,`themeforresearch`,`Abstract`) VALUES
('$_POST[name]','$_POST[address]','$_POST[Affiliation]','$_POST[Designation]','$_POST[telephone]','$_POST[email]','$_POST[Regtype]','$_POST[paper]','$_POST[themeforResearch]','$_POST[Abstract]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "Your Information has Successfully Posted";
mysql_close($con);
}
// create email headers
$headers = 'From: '.$_POST['email']."\r\n".
'Reply-To: '.$_POST['email']."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for contacting us. We will be in touch with you very soon.
<?php
}
?>