SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Auto-directing to new site after form submit

    i have a script that gets a users profile.
    right now when it's submitted, it returns a link to the profile.
    would it be possible to just forward there after the user submits?
    i can't use header() cause stuff's being sent before the header. here's the code.
    PHP Code:
    <?
    $db_connect 
    mysql_connect(hostuserpw);
    include (
    'join_header.php');
    if (!
    $user_name) {
    ?>
    <center>Please enter the username for the member you wish to view.</center><br>
    <table width="250" cellspacing="0" cellpadding="0" align="center">
     <tr>
      <td width="50" align="left"><b><font size="2">Username:&nbsp;&nbsp;</b></font></td>
      <td width="50" align="left"><form action="<?=$PHP_SELF ?>" method="POST"><input type="text" name="user_name"></td>
     </tr>
     <tr>
      <td width="50">&nbsp;</td>
      <td width="200" align="center"><br><input type="submit" value="Get User Info"></form></td>
     </tr>
    </table>
    <?
    } else {
    $userid_query "SELECT * from 3dartisan_users WHERE username='$user_name'";
    $id_runquery mysql_db_query(dbname$userid_query$db_connect);
    $id_results mysql_fetch_array($id_runquery);
    $id $id_results[id];

    if (!
    $id_results[username]) {
    echo 
    "<center>Sorry, that is an invalid member. Press your back button and try again.</center>";
    } else {
    header("Location: http://www.3dartisan.net/profile.php?id=$id");
    include (
    'join_footer.php');
    exit;
    } }
    ?>
    Last edited by Defender1; Sep 19, 2001 at 00:18.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  2. #2
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The best solution would be to re-think your application layout so you don't send anything to the browser until the last possible moment - that way you can have header() calls, die() calls and so on without problems.

    If that's not an option then have a look at output buffering in PHP 4. Output buffering is an easy to use system that stores all output HTML in a "buffer" instead of actually sending it to the browser. If you want to issue a header command you can because the HTML has only been stored rather than being sent. Have a look in the chapter in the PHP manual for more information.

  3. #3
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    heh, it was as simple as moving that include at the top down into the first if.
    Thanks
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*


Bookmarks

Posting Permissions

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