in
this form admin fills detail of user (name, email, mobile no., country, state,
education category, other details, hobbies) and email is send to admin and
user.
<?php
include ("menu.php");
error_reporting(E_ALL);
include("config.php");
//==================================detail filled in form==============================
if (isset($_REQUEST['submit'])) {
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$mobile = $_REQUEST['mobile'];
$country = $_REQUEST['country'];
$state = $_REQUEST['state'];
$edu_category = $_REQUEST['edu_category'];
$other_detail = $_REQUEST['other_detail'];
$hobbies = implode(',', $_REQUEST['hobbies']);
$admin_id = $_SESSION['s_admin_id'];
$original_doc = basename($_FILES["file"]["name"]);
$target_path = "../p_project/uploads/";
$target_path = $target_path . basename($_FILES["file"]["name"]);
//====================details filled in form will be shown after submit==================
echo "<h3>Thank you, your form is submitted successfully.</h3> <br/>";
echo 'Your name is <b>' . $name . '</b> <br/><br/>';
echo 'Your email is <b>' . $email . '</b> <br/><br/>';
echo 'Your number is <b>' . $mobile . '</b><br/><br/>';
echo 'Your country is <b>' . $country . '</b><br/><br/>';
echo 'Your state is <b>' . $state . '</b><br/><br/>';
echo 'Your education is <b>' . $edu_category . '</b><br/><br/>';
echo 'Your education is <b>' . $other_detail . '</b><br/><br/>';
echo 'Your hobby is <b>' . $hobbies . '</b><br/><br/>';
echo 'Your file name is <b>' . $original_doc . '</b><br/><br/>';
echo 'Your file path is <b>' . $target_path . '</b><br/><br/>';
$sql = "insert into sign_up (id, name, email, mobile, country, state, edu_category, other_detail, hobbies, original_doc, doc_path, a_id) VALUES('', '$name', '$email', '$mobile', '$country', '$state', '$edu_category', '$other_detail', '$hobbies', '$original_doc','$target_path', '$admin_id')";
move_uploaded_file($_FILES["file"]['tmp_name'], "uploads/" . $_FILES['file']['name']); //to upload file on our $target_path = "../p_project/uploads/"
mysqli_query($con, $sql) or die(mysql_error());
//============================mail sent to admin with filled details ==============
$admin_id = $_SESSION['s_admin_id'];
$data = mysqli_query($con, "select * from admin where admin_id= '$admin_id'");
$res = mysqli_fetch_array($data);
if (isset($res['a_email'])){
$a_email= $res['a_email'];
date_default_timezone_set('Asia/Calcutta');
$date = date("j F, Y, g:i a");
$to = $a_email;
$email_subject = 'Sign Up form';
$message_body .= "Name: ".$name."\n";
$message_body .= "Email : ".$email."\n";
$message_body .= "Mobile : ".$mobile."\n";
$message_body .= "Country : ".$country."\n";
$message_body .= "state : ".$state."\n";
$message_body .= "Education Category : ".$edu_category."\n";
$message_body .= "Other Details : ".$other_detail."\n";
$message_body .= "Hobbies : ".$hobbies."\n";
$message_body .= "The form has been submitted on". $date;
mail($to, $email_subject, $message_body )or die("failed");
//============================mail sent to user with filled details ================================
date_default_timezone_set('Asia/Calcutta');
$date = date("j F, Y, g:i a");
$to = $_REQUEST["email"];
$email_subject = 'Your is succesfully submitted on '.$date;
$message_body .= "<br/>Thank you for filling our form\n";
$message_body .= "Name: ".$name."\n";
$message_body .= "Email : ".$email."\n";
$message_body .= "Mobile : ".$mobile."\n";
$message_body .= "Country : ".$country."\n";
$message_body .= "state : ".$state."\n";
$message_body .= "Education Category : ".$edu_category."\n";
$message_body .= "Other Details : ".$other_detail."\n";
$message_body .= "Hobbies : ".$hobbies."\n";
$message_body .= "The form has been submitted on". $date;
mail($to, $email_subject, $message_body)or die("Failed");
}
} else {
?>
<div class="contact_frm">
<h3>Contact Form</h3>
<form name="user_form" id="user_form" class="user_form" method="post" action="form.php" enctype="multipart/form-data" onsubmit=" return validateform()">
<!-- Name -->
<table>
<tr>
<td><label>Name:</label></td>
<td><input type="text" id="user_form_name" name="name"/></td>
<td> <span class="span1"></span></td>
</tr>
<tr>
<td><label>Email:</label></td>
<td> <input type="email" id="user_form_email" name="email"/></td>
<td><span class="span2"></span></td>
</tr>
<tr>
<td><label>Mobile:</label></td>
<td><input type="text" id="user_form_mobile" name="mobile"/></td>
<td><span class="span3"></span></td>
</tr>
<tr>
<td><label>Country:</label></td>
<td><select id="country" name="country"></select></td>
<td><span class="span4"></span></td>
</tr>
<tr>
<td><label>State: </label></td>
<td><select class="stateDropDown" name="state" id="state"></select></td>
<td><span class="span5"></span></td>
</tr>
<tr>
<td><div id="edu" class= "education">Education</div></td>
<td><input type="radio" name="edu_category" id="edu_category" value="postgraduate" />Post Graduate
<input type="radio" name="edu_category" id="edu_category" value="graduate" />Graduate</td>
<td><span class="span6"></span></td>
</tr>
<tr>
<td><label>Other Details</label></td>
<td><div id="selectList">
<label></label>
</div></td>
<td></td>
</tr>
<tr>
<td><label>Select Your Hobbies</label></td>
<td><input type="checkbox" name="hobbies[]" id="cricket" value="cricket">Cricket
<input type="checkbox" name="hobbies[]" id="football" value="football">Football
<input type="checkbox" name="hobbies[]" id="Hockey" value="Hockey">Hockey</td>
<td> <span class="span7"></span></td>
</tr>
<tr>
<td><label for="file">Upload New File:</label></td>
<td><input type="file" name="file" id="file"></td>
<td><span class="span8"></span></td>
</tr>
<tr>
<td><img id="loader" src="./img/loading.gif" style="display:none;"/></td>
<td><input type="submit" value="Submit" name ="submit" /></td>
<td></td>
</tr>
</table>
</form>
<?php
include ("menu.php");
error_reporting(E_ALL);
include("config.php");
//==================================detail filled in form==============================
if (isset($_REQUEST['submit'])) {
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$mobile = $_REQUEST['mobile'];
$country = $_REQUEST['country'];
$state = $_REQUEST['state'];
$edu_category = $_REQUEST['edu_category'];
$other_detail = $_REQUEST['other_detail'];
$hobbies = implode(',', $_REQUEST['hobbies']);
$admin_id = $_SESSION['s_admin_id'];
$original_doc = basename($_FILES["file"]["name"]);
$target_path = "../p_project/uploads/";
$target_path = $target_path . basename($_FILES["file"]["name"]);
//====================details filled in form will be shown after submit==================
echo "<h3>Thank you, your form is submitted successfully.</h3> <br/>";
echo 'Your name is <b>' . $name . '</b> <br/><br/>';
echo 'Your email is <b>' . $email . '</b> <br/><br/>';
echo 'Your number is <b>' . $mobile . '</b><br/><br/>';
echo 'Your country is <b>' . $country . '</b><br/><br/>';
echo 'Your state is <b>' . $state . '</b><br/><br/>';
echo 'Your education is <b>' . $edu_category . '</b><br/><br/>';
echo 'Your education is <b>' . $other_detail . '</b><br/><br/>';
echo 'Your hobby is <b>' . $hobbies . '</b><br/><br/>';
echo 'Your file name is <b>' . $original_doc . '</b><br/><br/>';
echo 'Your file path is <b>' . $target_path . '</b><br/><br/>';
$sql = "insert into sign_up (id, name, email, mobile, country, state, edu_category, other_detail, hobbies, original_doc, doc_path, a_id) VALUES('', '$name', '$email', '$mobile', '$country', '$state', '$edu_category', '$other_detail', '$hobbies', '$original_doc','$target_path', '$admin_id')";
move_uploaded_file($_FILES["file"]['tmp_name'], "uploads/" . $_FILES['file']['name']); //to upload file on our $target_path = "../p_project/uploads/"
mysqli_query($con, $sql) or die(mysql_error());
//============================mail sent to admin with filled details ==============
$admin_id = $_SESSION['s_admin_id'];
$data = mysqli_query($con, "select * from admin where admin_id= '$admin_id'");
$res = mysqli_fetch_array($data);
if (isset($res['a_email'])){
$a_email= $res['a_email'];
date_default_timezone_set('Asia/Calcutta');
$date = date("j F, Y, g:i a");
$to = $a_email;
$email_subject = 'Sign Up form';
$message_body .= "Name: ".$name."\n";
$message_body .= "Email : ".$email."\n";
$message_body .= "Mobile : ".$mobile."\n";
$message_body .= "Country : ".$country."\n";
$message_body .= "state : ".$state."\n";
$message_body .= "Education Category : ".$edu_category."\n";
$message_body .= "Other Details : ".$other_detail."\n";
$message_body .= "Hobbies : ".$hobbies."\n";
$message_body .= "The form has been submitted on". $date;
mail($to, $email_subject, $message_body )or die("failed");
//============================mail sent to user with filled details ================================
date_default_timezone_set('Asia/Calcutta');
$date = date("j F, Y, g:i a");
$to = $_REQUEST["email"];
$email_subject = 'Your is succesfully submitted on '.$date;
$message_body .= "<br/>Thank you for filling our form\n";
$message_body .= "Name: ".$name."\n";
$message_body .= "Email : ".$email."\n";
$message_body .= "Mobile : ".$mobile."\n";
$message_body .= "Country : ".$country."\n";
$message_body .= "state : ".$state."\n";
$message_body .= "Education Category : ".$edu_category."\n";
$message_body .= "Other Details : ".$other_detail."\n";
$message_body .= "Hobbies : ".$hobbies."\n";
$message_body .= "The form has been submitted on". $date;
mail($to, $email_subject, $message_body)or die("Failed");
}
} else {
?>
<div class="contact_frm">
<h3>Contact Form</h3>
<form name="user_form" id="user_form" class="user_form" method="post" action="form.php" enctype="multipart/form-data" onsubmit=" return validateform()">
<!-- Name -->
<table>
<tr>
<td><label>Name:</label></td>
<td><input type="text" id="user_form_name" name="name"/></td>
<td> <span class="span1"></span></td>
</tr>
<tr>
<td><label>Email:</label></td>
<td> <input type="email" id="user_form_email" name="email"/></td>
<td><span class="span2"></span></td>
</tr>
<tr>
<td><label>Mobile:</label></td>
<td><input type="text" id="user_form_mobile" name="mobile"/></td>
<td><span class="span3"></span></td>
</tr>
<tr>
<td><label>Country:</label></td>
<td><select id="country" name="country"></select></td>
<td><span class="span4"></span></td>
</tr>
<tr>
<td><label>State: </label></td>
<td><select class="stateDropDown" name="state" id="state"></select></td>
<td><span class="span5"></span></td>
</tr>
<tr>
<td><div id="edu" class= "education">Education</div></td>
<td><input type="radio" name="edu_category" id="edu_category" value="postgraduate" />Post Graduate
<input type="radio" name="edu_category" id="edu_category" value="graduate" />Graduate</td>
<td><span class="span6"></span></td>
</tr>
<tr>
<td><label>Other Details</label></td>
<td><div id="selectList">
<label></label>
</div></td>
<td></td>
</tr>
<tr>
<td><label>Select Your Hobbies</label></td>
<td><input type="checkbox" name="hobbies[]" id="cricket" value="cricket">Cricket
<input type="checkbox" name="hobbies[]" id="football" value="football">Football
<input type="checkbox" name="hobbies[]" id="Hockey" value="Hockey">Hockey</td>
<td> <span class="span7"></span></td>
</tr>
<tr>
<td><label for="file">Upload New File:</label></td>
<td><input type="file" name="file" id="file"></td>
<td><span class="span8"></span></td>
</tr>
<tr>
<td><img id="loader" src="./img/loading.gif" style="display:none;"/></td>
<td><input type="submit" value="Submit" name ="submit" /></td>
<td></td>
</tr>
</table>
</form>
php programming sample codes
ReplyDeletephp script - Image Upload And Resize Script