#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    61
    Rep Power
    14
    In using a submit form is there a way to NOT reload the form page but go directly to the redirect page? (after inserting of course) Also I am using html to redirect. Is there a better, php way to do this? Below is an example code.
    ************************************
    if ($submit)
    {
    $sql = "INSERT INTO newspapers (pname,city,state,url,phone) VALUES ('$pname','$city','$state','$url','$phone')";
    $result = mysql_query($sql);
    echo "<br><BR>Thank you! Information entered. n";
    ?>
    <meta http-equiv="refresh" content="0 ; url=http://xxxxxxxxx.com">
    <?php
    }
    }
    else
    {
    // display form
    ?>
    <form method="post" action="<?php echo $PHP_SELF?>">
    <table border=0 width="100%" cellspacing="5">
    <tr>
    <td align=right width="25%"><sup><font color=#cc0000>*</font></sup><b>Paper Name: </b></td>
    <TD width="*"><input type="Text" name="pname"></td>
    </tr>
    <tr><td align=right valign=top><b>City: </b></td>
    <TD valign=top><input type="Text" name="city"></td>
    </tr>
    <td align=right valign=top><b>State: </b></td>
    <TD align=left valign=top><select name="state" size="1">
    <OPTION>CO</OPTION>
    <OPTION>KS</OPTION>
    </SELECT>

    </td>
    </tr>
    <tr><td align=right valign=top><b>Phone: </b></td>
    <TD valign=top><input type="Text" name="phone"></td>
    </tr>
    <tr><td align=right valign=top><b>Web Address: </b><BR><font=-1>Remember http:// </font></td>
    <TD valign=top><input type="Text" name="url"></td>
    </tr>
    <tr>
    <td></td>
    </tr>
    </table>
    <input type="Submit" name="submit" value="Enter information">
    </form>
    <?php
    } // end if
    ?>
    *************************************

    Thanks,

    stuart
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    either 1)
    action="<?php echo $PHP_SELF?>"><= change the action to go straight to the receiving page and do the sql there... or

    2)do this
    <?
    if ($submit){
    $sql = "INSERT INTO newspapers (pname,city,state,url,phone) VALUES ('$pname','$city','$state','$url','$phone')";
    $result = mysql_query($sql);
    if($result){
    header("Location: other_page.php?result=$result"); }}

    if(!$submit){ etc etc...


    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    61
    Rep Power
    14
    Thanks for the help. Since this all is new it doesn't jive until I see the code, then it seems so obvious. I will get to work, thanks again.
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    either 1)
    action="<?php echo $PHP_SELF?>"><= change the action to go straight to the receiving page and do the sql there... or

    2)do this
    <?
    if ($submit){
    $sql = "INSERT INTO newspapers (pname,city,state,url,phone) VALUES ('$pname','$city','$state','$url','$phone')";
    $result = mysql_query($sql);
    if($result){
    header("Location: other_page.php?result=$result"); }}

    if(!$submit){ etc etc...


    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL

Similar Threads

  1. Forms, Frames, and URLs (newbie)
    By thereuare in forum PHP Development
    Replies: 6
    Last Post: February 15th, 2004, 03:20 AM
  2. pdf forms?
    By bellcom in forum Web Design Help
    Replies: 0
    Last Post: January 31st, 2004, 09:08 PM
  3. Putting/submitting lots of forms on one page
    By rampguy in forum PHP Development
    Replies: 1
    Last Post: December 5th, 2003, 10:47 PM
  4. newbie question Forms to MySQL
    By dvx_movies in forum PHP Development
    Replies: 3
    Last Post: November 5th, 2003, 10:42 AM
  5. Newbie question on forms in Excel VB
    By hweinstein in forum Visual Basic Programming
    Replies: 2
    Last Post: October 31st, 2003, 06:52 AM

IMN logo majestic logo threadwatch logo seochat tools logo