PHP Coding Help

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

sakshi1311
New php-forum User
New php-forum User
Posts: 5
Joined: Thu Jan 03, 2013 1:50 am

PHP Coding Help

Postby sakshi1311 » 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

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

Re: PHP Coding Help

Postby sendy » Thu Jan 03, 2013 7:00 am

mind if u show what have u done so far?

sakshi1311
New php-forum User
New php-forum User
Posts: 5
Joined: Thu Jan 03, 2013 1:50 am

Re: PHP Coding Help

Postby sakshi1311 » 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

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: PHP Coding Help

Postby seandisanti » Fri Jan 04, 2013 9:25 am

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

sakshi1311
New php-forum User
New php-forum User
Posts: 5
Joined: Thu Jan 03, 2013 1:50 am

Re: PHP Coding Help

Postby sakshi1311 » 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">
<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">&nbsp;</td>
<td width="50" height="30">&nbsp;</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>

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

Re: PHP Coding Help

Postby simplypixie » 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");

sakshi1311
New php-forum User
New php-forum User
Posts: 5
Joined: Thu Jan 03, 2013 1:50 am

Re: PHP Coding Help

Postby sakshi1311 » Mon Jan 14, 2013 12:19 am

Thank You :)


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google Feedfetcher and 4 guests

cron