PHP Coding Help

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply

Thu Jan 03, 2013 2:09 am

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

New php-forum User
New php-forum User
Posts: 9
Joined: Thu Oct 25, 2012 9:47 pm

Thu Jan 03, 2013 7:00 am

mind if u show what have u done so far?


Thu Jan 03, 2013 8:28 pm

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
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Fri Jan 04, 2013 9:25 am

you can copy the contents of the file into [ code=php ] blocks (without the spaces)


Mon Jan 07, 2013 5:26 am

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">
<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">
<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>
<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>
<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>
<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>
<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>
<td width="130" height="30" class="Body_text3">&nbsp;</td>
<td width="50" height="30">&nbsp;</td>
<td width="420" height="30"><input type="submit" id="submit" value=" " class="submitButtonFormat" / ></td>

} else {
// initialize a array to
//hold any errors we encounter
$errors = array();
// test to see if the form was actually
// posted from our form
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 = '';
$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.";



User avatar
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire

Mon Jan 07, 2013 11:13 pm

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");

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests