Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-20-2012, 02:52 AM   PM User | #1
yourwebgurus
New to the CF scene

 
Join Date: Jun 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
yourwebgurus is an unknown quantity at this point
Help with some basic PHP

Hey all Im no PHP expert was hoping someone could help me with an issue on a site Im updating.

The site currently has some PHP forms, but there is not a clear confirmation/thank you page, and I am trying to install an Adwords conversion (javascript) to render after a form submission.

Here is the code in the header of each page

<?php
if($_SERVER['REQUEST_METHOD']=="POST") {
extract($_POST);
$IP=$_SERVER["REMOTE_ADDR"];
$SUBJECT="Lead";
$MESSAGE1.="<font style='font-family:Georgia, serif; font-size:12px;'>";
$MESSAGE1.="Message via contact form on website:<br /><br />
<strong>Name :</strong> ".$name."<br/>
<strong>Phone :</strong> ".$phone."<br/>
<strong>Address :</strong> ".$address."<br/>
<strong>Zip Code :</strong> ".$zipcode."<br/>
<strong>Job Type :</strong> ".$jobtype."<br/>
<strong>Urgency Level :</strong> ".$urgency."<br/>
<strong>IP address</strong> : ".$IP."<br/><br/>";

$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $name\r\n";
$headers .= "Return-Path: $name <myemail@yahoo.com>\r\n";
// $email="myemail@yahoo.com";
$email="myemail@yahoo.com";
if(mail($email, $SUBJECT, $MESSAGE1, $headers)){
echo '<script>window.location.href="?s=success";</script>'; }
//echo "Email Sent Successfully to ".$fname." (".$femail.").";
}

and then... in the body of the html

<form method="POST" action="" >
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td>&nbsp;</td></tr>
<tr>
<td width="100%"><font size="2" face="Verdana" color="#18181D"><? if(isset($_REQUEST["s"])) { echo "<b>Your form has been submitted.</b>"; } else { echo "";}?></font></td>
</tr>
<tr>
<td width="100%">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="formtext" width="45%" valign="top">
<p style="margin-left: 5">Name</p>
</td>
<td width="55%"><input type="text" name="name" id="name" class="searchbox"></td>
</tr>
ETC
ETC
ETC

I was thinking of trying to get the conversion script somehow in the "echo" lines .. but not sure how to do that... otherwise if there is a way to just make it redirect to a static page, I could create the static thankyou.html page and take it from there.

Any advice?

Thanks guys I really appreciate any help you can give.
yourwebgurus is offline   Reply With Quote
Old 06-20-2012, 04:33 AM   PM User | #2
DrDOS
Senior Coder

 
Join Date: Sep 2010
Posts: 1,146
Thanks: 10
Thanked 148 Times in 148 Posts
DrDOS is infamous around these parts
You can make it so that PHP injects a message directly into your javascript. At the top of the php you can have:
PHP Code:
$submit_message = "";
then in the _post part of the php
$submit_message = "Your information was successfully submitted.";
then in the javascript
<?php echo 'message_box.innerHTML = "'.$submit_message.'"'?>
That way you can verity the submission before you send the message.

Last edited by DrDOS; 06-20-2012 at 04:37 AM..
DrDOS is offline   Reply With Quote
Old 06-20-2012, 09:44 PM   PM User | #3
yourwebgurus
New to the CF scene

 
Join Date: Jun 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
yourwebgurus is an unknown quantity at this point
Im not sure I understand..

What Im trying to do is create a redirect to a new html page to use as the thank you page... isnt there some code I put in there so that it just redirects the person after the form is submitted?

Thanks again for your help
yourwebgurus is offline   Reply With Quote
Old 06-20-2012, 10:55 PM   PM User | #4
DrDOS
Senior Coder

 
Join Date: Sep 2010
Posts: 1,146
Thanks: 10
Thanked 148 Times in 148 Posts
DrDOS is infamous around these parts
Sorry, I misunderstood that you wanted a new page. Just use the header redirect, here is how it's done, straight from the php manual.
PHP Code:

<?php
header
("Location: http://www.example.com/"); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?>
Put it at the bottom of the code that gets executed.
DrDOS is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:17 PM.


Advertisement
Log in to turn off these ads.