Demo --
Question.php --- Client will answer this 5 questions then
After click on next button it goes to result page which having 2 div. one with contact form and second with result of this calculation
In contact form all fields are compulsory and after submitting the info will go to my id and open second div
PHP Coding Help
Moderators: egami, macek, gesf
hi...when i was uploading the file i get error can you please tell me how can i show that file
-
- php-forum Fan User
- Posts: 973
- Joined: Mon Oct 01, 2012 12:32 pm
you can copy the contents of the file into [ code=php ] blocks (without the spaces)
Below mentioned are the code.... Can anybody please help me with this...
Where in this code can I add the action so that after someone fills the contact form it goes to the next page
<div id="div1">
<table width="675" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="522" class="calc_deatil_bg">
<div >
<?php if ($_SERVER['REQUEST_METHOD'] != 'POST')
{ $me = $_SERVER['PHP_SELF'] ;?>
<form name="form1" method="post" action="<?=$me?>" >
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="130" height="30" class="calc_text_result">Name</td>
<td width="50" height="30" class="calc_text_result">:</td>
<td width="420" height="30">
<input name="name" type="text" id="name2" class="calcTextField" required size="26" onBlur="notEmpty('name','This field is required','name_message')" /><div id='name_message' class="error_strings"></div></td>
</tr>
<tr>
<td width="130" height="30" class="calc_text_result">E-mail</td>
<td width="50" height="30" class="calc_text_result">:</td>
<td width="420" height="30">
<input name="email" id="email" class="calcTextField" required size="26" type="text" onblur="notEmpty('email','This field is required','email_message'); emailValidator('email','Invalid email','email_message') " /><div id='email_message' class="error_strings"></div> </td>
</tr>
<tr>
<td width="130" height="30" class="calc_text_result">Phone</td>
<td width="50" height="30" class="calc_text_result">:</td>
<td width="420" height="30">
<input name="phno" id="phno" class="calcTextField" required size="10" type="text" onblur="isnumeric('tel','This field is required','tel_message')" /><div id='tel_message' class="error_strings"></div></td>
</tr>
<tr>
<td width="130" height="30" class="calc_text_result">Organization</td>
<td width="50" height="30" class="calc_text_result">:</td>
<td width="420" height="30">
<input name="comp" id="comp" class="calcTextField" required size="26" type="text" onblur="notEmpty('company','This field is required','com_message')" /><div id='com_message' class="error_strings"></div> </td>
</tr>
<tr>
<td width="130" height="30" class="calc_text_result">Address</td>
<td width="50" height="30" class="calc_text_result">:</td>
<td width="420" height="30"><textarea name="addr" id="addr" class="calcTextField" required size="60" type="text" onblur="notEmpty('app','This field is required','app_message')" ></textarea><div id='app_message' class="error_strings"></div></td>
</tr>
<tr>
<td width="130" height="30" class="Body_text3"> </td>
<td width="50" height="30"> </td>
<td width="420" height="30"><input type="submit" id="submit" value=" " class="submitButtonFormat" / ></td>
</tr>
</table>
</form><?php
} else {
error_reporting(7);
// initialize a array to
//hold any errors we encounter
$errors = array();
// test to see if the form was actually
// posted from our form
$page = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
if (!ereg($page, $_SERVER['HTTP_REFERER']))
$errors[] = "Invalid referer<br>\n";
// check to see if detail was entered
if (!$_POST['name'])
$errors[] = "Name is required";
if (!$_POST['addr'])
$errors[] = "Address is required";
if (!$_POST['phno'])
$errors[] = "Phone No is required";
if (!$_POST['email'])
$errors[] = "Email Id is required";
// if there are any errors, display them
if (count($errors)>0) {
foreach($errors as $err)
echo "$err<br>\n";
echo "<br>Please use your browser's Back button to fix.";
} else {
// no errors, so we build our message
$recipient = 'shubhangee.kulkarni@inventurus.in';
$subject = "Cash Calculator Contact Us";
$from = stripslashes($_POST['name']);
$headers = "From: $from";
$msg = "Message sent by $from\n";
$msg.="\nName: ".stripslashes($_POST['name'])."\n";
$msg.="\nEmail Id: ".stripslashes($_POST['email'])."\n";
$msg.="\nCompany: ".stripslashes($_POST['comp'])."\n";
$msg.="\nContact No: ".stripslashes($_POST['phno'])."\n";
$msg.="\nAddress: ".stripslashes($_POST['addr'])."\n";
if (mail($recipient,$subject,$msg,$headers)){
echo "";
} else
echo "An unknown error occurred.";
}
}
?>
</div>
</td>
</tr>
</table>
</div>

Where in this code can I add the action so that after someone fills the contact form it goes to the next page
<div id="div1">
<table width="675" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="522" class="calc_deatil_bg">
<div >
<?php if ($_SERVER['REQUEST_METHOD'] != 'POST')
{ $me = $_SERVER['PHP_SELF'] ;?>
<form name="form1" method="post" action="<?=$me?>" >
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="130" height="30" class="calc_text_result">Name</td>
<td width="50" height="30" class="calc_text_result">:</td>
<td width="420" height="30">
<input name="name" type="text" id="name2" class="calcTextField" required size="26" onBlur="notEmpty('name','This field is required','name_message')" /><div id='name_message' class="error_strings"></div></td>
</tr>
<tr>
<td width="130" height="30" class="calc_text_result">E-mail</td>
<td width="50" height="30" class="calc_text_result">:</td>
<td width="420" height="30">
<input name="email" id="email" class="calcTextField" required size="26" type="text" onblur="notEmpty('email','This field is required','email_message'); emailValidator('email','Invalid email','email_message') " /><div id='email_message' class="error_strings"></div> </td>
</tr>
<tr>
<td width="130" height="30" class="calc_text_result">Phone</td>
<td width="50" height="30" class="calc_text_result">:</td>
<td width="420" height="30">
<input name="phno" id="phno" class="calcTextField" required size="10" type="text" onblur="isnumeric('tel','This field is required','tel_message')" /><div id='tel_message' class="error_strings"></div></td>
</tr>
<tr>
<td width="130" height="30" class="calc_text_result">Organization</td>
<td width="50" height="30" class="calc_text_result">:</td>
<td width="420" height="30">
<input name="comp" id="comp" class="calcTextField" required size="26" type="text" onblur="notEmpty('company','This field is required','com_message')" /><div id='com_message' class="error_strings"></div> </td>
</tr>
<tr>
<td width="130" height="30" class="calc_text_result">Address</td>
<td width="50" height="30" class="calc_text_result">:</td>
<td width="420" height="30"><textarea name="addr" id="addr" class="calcTextField" required size="60" type="text" onblur="notEmpty('app','This field is required','app_message')" ></textarea><div id='app_message' class="error_strings"></div></td>
</tr>
<tr>
<td width="130" height="30" class="Body_text3"> </td>
<td width="50" height="30"> </td>
<td width="420" height="30"><input type="submit" id="submit" value=" " class="submitButtonFormat" / ></td>
</tr>
</table>
</form><?php
} else {
error_reporting(7);
// initialize a array to
//hold any errors we encounter
$errors = array();
// test to see if the form was actually
// posted from our form
$page = $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
if (!ereg($page, $_SERVER['HTTP_REFERER']))
$errors[] = "Invalid referer<br>\n";
// check to see if detail was entered
if (!$_POST['name'])
$errors[] = "Name is required";
if (!$_POST['addr'])
$errors[] = "Address is required";
if (!$_POST['phno'])
$errors[] = "Phone No is required";
if (!$_POST['email'])
$errors[] = "Email Id is required";
// if there are any errors, display them
if (count($errors)>0) {
foreach($errors as $err)
echo "$err<br>\n";
echo "<br>Please use your browser's Back button to fix.";
} else {
// no errors, so we build our message
$recipient = 'shubhangee.kulkarni@inventurus.in';
$subject = "Cash Calculator Contact Us";
$from = stripslashes($_POST['name']);
$headers = "From: $from";
$msg = "Message sent by $from\n";
$msg.="\nName: ".stripslashes($_POST['name'])."\n";
$msg.="\nEmail Id: ".stripslashes($_POST['email'])."\n";
$msg.="\nCompany: ".stripslashes($_POST['comp'])."\n";
$msg.="\nContact No: ".stripslashes($_POST['phno'])."\n";
$msg.="\nAddress: ".stripslashes($_POST['addr'])."\n";
if (mail($recipient,$subject,$msg,$headers)){
echo "";
} else
echo "An unknown error occurred.";
}
}
?>
</div>
</td>
</tr>
</table>
</div>
- simplypixie
- php-forum Active User
- Posts: 300
- Joined: Sun Dec 11, 2011 12:51 am
- Location: Shrewsbury, Shropshire
- Contact:
If I understand correctly, once you have done all your checks, sent the email etc you just need to use a header redirect:
Code: Select all
header("location: name_of_page_to_redirect_to.php");