Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,929
    Thanks
    15
    Thanked 229 Times in 229 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,929
    Thanks
    15
    Thanked 229 Times in 229 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •