need tiny bit of code

Discussion in 'PHP' started by whocky, May 10, 2008.

  1. #1
    Hi all

    Im looking for some code to redirect a form to a thank you page after its submitted.

    The script im using atthe moment is ok, though has a seperate file with all the info like were to send the email etc.

    all i need is a bit of code to redirect it and were to put it.

    hope someone can help

    Whocky
     
    whocky, May 10, 2008 IP
  2. kreoton

    kreoton Peon

    Messages:
    229
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    very simple:
    header('location: thankyou.php');
    PHP:
    header function must be called before any output ;)
     
    kreoton, May 10, 2008 IP
  3. Blazej

    Blazej Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    if anything called before any output uoy must set in first line in you document

    
    ob_start();
    
    Code (markup):
     
    Blazej, May 10, 2008 IP
  4. whocky

    whocky Active Member

    Messages:
    124
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Hi

    I cant seem to get this to work so im just going to show you guys the form:

    quote.php lookes like this, ( this is the form )

    All i want this to do is once submitted goto a thank you page.
    Hope someone can help

    "><form name="phpformmailer" action="quoteemail.php" align="center" method="post">   
     <p align="left" class="style6"><b><font size="3"> 
                <!-- DO NOT change ANY of the php sections -->
            </font></b></p>
              
          <p align="left" class="style6"><b><font size="3"> 
            <?php
    $ipi = getenv("REMOTE_ADDR");
    $httprefi = getenv ("HTTP_REFERER");
    $httpagenti = getenv ("HTTP_USER_AGENT");
    ?>
            </font></b><span class="style8">Welcome to our online quote form. Please 
            fill in all fields. </span><b><font size="3"> <br />
            <input type="hidden" name="ip" value="<?php echo $ipi ?>" />
            <input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
            <input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />
            <span class="style8"><font color="#000000" size="2">Name: </font></span><font color="#000000" size="2"><br />
            <input name="name" type="text" id="name" size="35" />
            <br />
            <span class="style8">Address:</span><br />
            <textarea name="Address" cols="35" id="Address"></textarea>
            <br />
            <span class="style8">Telephone Number:</span> </font></font></b><font color="#000000" size="2"><span class="style6"><b> 
            <label> 
            <input name="Telephone" type="text" id="Telephone" />
            </label>
            <br />
            Email address :<br />
            <input name="email" type="text" id="email" size="35" />
            <br />
            <label></label>
            <br />
            Day: 
            <label> 
            <select name="day" id="day">
              <option value="Monday">Monday</option>
              <option value="Tuesday">Tuesday</option>
              <option value="Wednesday">Wednesday</option>
              <option value="Thursday">Thursday</option>
              <option value="Friday">Friday</option>
              <option value="Saturday">Saturday</option>
              <option value="Sunday">Sunday</option>
            </select>
            </label>
            Date: 
            <label> 
            <select name="date" id="date">
              <option value="1st">1st</option>
              <option value="2nd">2nd</option>
              <option value="3rd">3rd</option>
              <option value="4th">4th</option>
              <option value="5th">5th</option>
              <option value="6th">6th</option>
              <option value="7th">7th</option>
              <option value="8th">8th</option>
              <option value="9th">9th</option>
              <option value="10th">10th</option>
              <option value="11th">11th</option>
              <option value="12th">12th</option>
              <option value="13th">13th</option>
              <option value="14th">14th</option>
              <option value="15th">15th</option>
              <option value="16th">16th</option>
              <option value="17th">17th</option>
              <option value="18th">18th</option>
              <option value="19th">19th</option>
              <option value="20th">20th</option>
              <option value="21st">21st</option>
              <option value="22nd">22nd</option>
              <option value="23rd">23rd</option>
              <option value="24th">24th</option>
              <option value="25th">25th</option>
              <option value="26th">26th</option>
              <option value="27th">27th</option>
              <option value="28th">28th</option>
              <option value="29th">29th</option>
              <option value="30th">30th</option>
              <option value="31st">31st</option>
            </select>
            </label>
            month: 
            <label> 
            <select name="month" id="month">
              <option value="January">January</option>
              <option value="February">February</option>
              <option value="March">March</option>
              <option value="April">April</option>
              <option value="May">May</option>
              <option value="June">June</option>
              <option value="July">July</option>
              <option value="August">August</option>
              <option value="September">September</option>
              <option value="October">October</option>
              <option value="November">November</option>
              <option value="December">December</option>
            </select>
            </label>
            Year: 
            <label> 
            <select name="Year" id="Year">
              <option value="2008">2008</option>
              <option value="2009">2009</option>
              <option value="2010">2010</option>
            </select>
            </label>
            Collection Time: 
            <label> 
            <input name="CollectionTime" type="text" id="CollectionTime" size="9" />
            </label>
            <label> 
            <select name="select">
              <option value="Am">Am</option>
              <option value="Pm">Pm</option>
            </select>
            </label>
            <br />
            <br />
            From: 
            <label></label>
            <label> 
            <input name="From" type="text" id="From" />
            </label>
            Destination: 
            <label> 
            <input name="Destination" type="text" id="Destination" />
            </label>
            <br />
            Event: 
            <label> 
            <select name="Event" id="Event">
              <option value="Baby arrival">Baby arrival</option>
              <option value="Birthday">Birthday</option>
              <option value="Wedding">Wedding</option>
              <option value="Stag night">Stag night</option>
              <option value="Races">Races</option>
              <option value="Hen night">Hen night</option>
              <option value="Business">Business</option>
              <option value="Airports">Airports</option>
              <option value="Christening">Christening</option>
              <option value="Prom">Prom</option>
              <option value="Other">Other</option>
            </select>
            </label>
            Adults or kids: 
            <label> 
            <select name="AdultsOrKids" id="AdultsOrKids">
              <option value="Adults">Adults</option>
              <option value="Kids">Kids</option>
              <option value="Adults and Kids">Adults and Kids</option>
            </select>
            </label>
            <br />
            <br />
            How many people: 
            <label> 
            <select name="HowManyPeople" id="HowManyPeople">
              <option value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
              <option value="5">5</option>
              <option value="6">6</option>
              <option value="7">7</option>
              <option value="8" selected="selected">8</option>
            </select>
            <br />
            By submitting this form you automatically agree to our <a href="http://www.alfalimos.com/termsandconditions.htm" target="_blank">Terms 
            and Conditions</a></label>
            </b></span></font> </p>
              <div align="center"><span class="style6"><b><font size="3">
                <input type="submit" value="Submit Quote" />
            </font></b></span> </div>
        </form>
    Code (markup):
    this is the file it goes to so it can email it to me,

    quoteemail.php
    <?
    $ToEmail = 'test@test.com';
    $EmailSubject = 'Online Quote';
    $mailheader = "From: ".$_POST["email"]."\r\n";
    $mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
    $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
    $MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
    $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>";
    $MESSAGE_BODY .= "Address: ".nl2br($_POST["Address"])."<br>";
    $MESSAGE_BODY .= "Telephone: ".nl2br($_POST["Telephone"])."<br>";
    $MESSAGE_BODY .= "Mobile: ".nl2br($_POST["mobile"])."<br>";
    $MESSAGE_BODY .= "How Many Cars: ".nl2br($_POST["HowManyCars"])."<br>";
    $MESSAGE_BODY .= "Day: ".nl2br($_POST["day"])."<br>";
    $MESSAGE_BODY .= "Date: ".nl2br($_POST["date"])."<br>";
    $MESSAGE_BODY .= "Month: ".nl2br($_POST["month"])."<br>";
    $MESSAGE_BODY .= "Year: ".nl2br($_POST["Year"])."<br>";
    $MESSAGE_BODY .= "Collection Time: ".nl2br($_POST["CollectionTime"])."<br>";
    $MESSAGE_BODY .= "picked up from: ".nl2br($_POST["From"])."<br>";
    $MESSAGE_BODY .= "Destination: ".nl2br($_POST["Destination"])."<br>";
    $MESSAGE_BODY .= "Event: ".nl2br($_POST["Event"])."<br>";
    $MESSAGE_BODY .= "Adult Or kids: ".nl2br($_POST["AdultsOrKids"])."<br>";
    $MESSAGE_BODY .= "How Many People: ".nl2br($_POST["HowManyPeople"])."<br>";
    mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die("Failure"); 
    Code (markup):
     
    whocky, May 10, 2008 IP
  5. hip_hop_x

    hip_hop_x Active Member

    Messages:
    522
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #5
    or you could use javascript
    <?php echo "<script>function newlink(){
    window.location.href='http://mydomain.com/thankyou.php';
    }</script>";
    ?>
    PHP:
     
    hip_hop_x, May 10, 2008 IP