PHP for a thankyou.html to load after form submit

Discussion in 'PHP' started by tmos_ash, Sep 30, 2007.

  1. #1
    I was wondering if I could get some help with PHP. I have a form that works well with serverside PHP. However, when the user hits submit it opens up my "blank" PHP URL. can anyonle help me figure out how I can send an automatic "thankyou.html" upon them pressing "submit"


    Here is the Form HTML and the PHP is after:


    <td style="height:233px;"><form method="post" action="http://www.mywebsite.com/cgi-bin/contactx.php" id="form"><table border="0" cellpadding="0" cellspacing="0" style="margin:12px 0 0 18px; width:181px;">
    <tr><td><img src="images/7title4.jpg" alt="" style="margin-bottom:17px;"></td></tr>
    <tr>
    <td><label>
    <input name="name" type="text" id="name" value="Name:">
    </label></td>
    </tr>
    <tr><td><img src="images/spacer.gif" width="1" height="8" alt=""></td></tr>
    <tr>
    <td><label>
    <input name="email" type="text" id="email" value="Email:">
    </label></td>
    </tr>
    <tr><td><img src="images/spacer.gif" width="1" height="8" alt=""></td></tr>
    <tr>
    <td><label>
    <input name="subject" type="text" id="subject" value="Subject:">
    </label></td>
    </tr>
    <tr><td><img src="images/spacer.gif" width="1" height="8" alt=""></td></tr>
    <tr>
    <td><label>
    <textarea name="message" id="message" cols="45" rows="5">Message:

    </textarea>
    </label></td>
    </tr>
    <tr>
    <td><table border="0" cellpadding="0" cellspacing="0" style="margin:5px 0 0 80px;" class="kn">
    <tr>
    <td width="60" style="width:60px;"><a href="#" onclick="document.getElementById('form').reset()">clear</a><img src="images/ch_1.jpg" style="margin-left:4px; margin-top:5px;" alt=""></td>
    <td width="39"><a href="#" onclick="document.getElementById('form').submit()">send</a>



    Here is the PHP

    <?php

    // setting variables

    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];

    // sending message to the recipient

    $to = "myemail@mail.com";
    $subject = $_POST['subject'];
    $msg = $message . $_POST['name'] .
    $headers = "From: " . $_POST['email'] . "\r\nReply-To:" . $_POST['email'];


    mail("$to", "$subject", "$msg", "$headers");

    ?>
     
    tmos_ash, Sep 30, 2007 IP
  2. romeo2010

    romeo2010 Peon

    Messages:
    183
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    on your result page input this
    <META http-equiv="refresh" content="0;
    URL=http://www.vipdesi.com/tube/">


    it will redirect ou to the thank you page
     
    romeo2010, Sep 30, 2007 IP
  3. khan11

    khan11 Active Member

    Messages:
    615
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #3
    
    <form method="post" action="http://www.mywebsite.com/cgi-bin/contactx.php" id="form">
    <input type="hidden" name="redirect" value="thankyoupage.htm" />
    
    Code (markup):
    try this
     
    khan11, Sep 30, 2007 IP
  4. indianseo

    indianseo Peon

    Messages:
    208
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try this..

    
    <?php
    
    // setting variables
    
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    
    // sending message to the recipient
    
    $to = "myemail@mail.com";
    $subject = $_POST['subject'];
    $msg = $message . $_POST['name'] .
    $headers = "From: " . $_POST['email'] . "\r\nReply-To:" . $_POST['email'];
    
    
    mail("$to", "$subject", "$msg", "$headers");
    
    [B]header("Location: thankyou.html");[/B]
    ?>
    
    Code (markup):
     
    indianseo, Oct 1, 2007 IP
  5. tmos_ash

    tmos_ash Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thank you all for the help khan11 and indianseo... both methods worked.
     
    tmos_ash, Oct 1, 2007 IP