SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Enthusiast guz's Avatar
    Join Date
    Dec 2001
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to redirect this php command

    <? echo $PHP_SELF ?>

    how do i get the page to default to my web forum after the client submits their information....
    '
    i am assuming this is the command that calls it?

    i want to call

    www.tantriczen.com/forums/

    after they submit the information

  2. #2
    What's HTML?
    Join Date
    May 2001
    Location
    San Diego, CA
    Posts
    1,701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your best option would be to use the standard HTML meta-refresh tag, which would point to your forum page. PHP also has a built-in function, header(), that can be used to forward the user to the desired page, but in your case the header() function won't work correctly.

    If you don't know how to do this, you'll need to post your PHP script here and someone will place the above tag in the proper location.
    Ryan Kuhle - A Proud Advisor - Got Questions? Just Ask!
    Get your website started for less than $20! Click Here

  3. #3
    SitePoint Enthusiast guz's Avatar
    Join Date
    Dec 2001
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this is the script

    <?
    mysql_connect("localhost", "fan", "pword");
    mysql_select_db("tantriczen_fanclub");

    if($submit) {
    $query = mysql_query("INSERT INTO fans VALUES('$last_name','$first_name','$email_address' ,'$phone_number','$street_address','$your_city','$state ','$zip','$event_date','$venue_city','$venue_name','$vif_date')");
    }
    ?>

  4. #4
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by guz
    this is the script

    <?
    mysql_connect("localhost", "fan", "pword");
    mysql_select_db("tantriczen_fanclub");

    if($submit) {
    $query = mysql_query("INSERT INTO fans VALUES('$last_name','$first_name','$email_address' ,'$phone_number','$street_address','$your_city','$state ','$zip','$event_date','$venue_city','$venue_name','$vif_date')");
    }
    ?>
    I have asked this once before and no one could give me an answer to work. So I ended up doing this.

    Wait hang on do you just want to submit a form to a different page? Or do you want when the query is succesful to redirect to a new page. ??

    If you want to redirect after the submit is successful then this is the way I do it. I haven;t found a php equivelent that works.

    Code:
    if($submit) { 
         $query = mysql_query("INSERT INTO fans  VALUES('$last_name','$first_name','$email_address' ,'$phone_number','$street_address','$your_city','$state ','$zip','$event_date','$venue_city','$venue_name','$vif_date')"    );
    <script language="javascript1.2">
    <!--
    top.location.href="new url";
    //-->
    </script>
    }
    If anyone can give you a php way that actually works I would 'LOVE' to see it

    If you are just trying to send the form to another page just change the action to the other page

    Code:
    <form action="http://other.url.com" method="post">
    ...
    </form>
    The header() is suppost to do this but I have yet to get that working. But it seems like the second option is you more viable one.
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  5. #5
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should work:
    Code:
    <?
    mysql_connect("localhost", "fan", "pword"); 
    mysql_select_db("tantriczen_fanclub"); 
    
    if($submit) { 
    $query = mysql_query("INSERT INTO fans  VALUES('$last_name','$first_name',
    '$email_address' ,'$phone_number','$street_address','$your_city',
    '$state ','$zip','$event_date','$venue_city','$venue_name','$vif_date')");
    }
    header("Location: http://www.tantriczen.com/forums/");
    ?>
    Last edited by Aes; Dec 31, 2001 at 02:33.
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  6. #6
    SitePoint Enthusiast guz's Avatar
    Join Date
    Dec 2001
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i had no idea that it was that easy..........

    all i wanted was it to go to the page after they submitted their information....tha is to easy thanks guys...................

  7. #7
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maelstrom


    I assume yours didn't work because you tried to implement header() after output had been started in the browser. Headers must precede any output including html code or whitespace.


    <?
    mysql_connect("localhost", "fan", "pword");
    mysql_select_db("tantriczen_fanclub");

    if($submit) {
    $query = mysql_query("INSERT INTO fans VALUES('$last_name','$first_name',
    '$email_address' ,'$phone_number','$street_address','$your_city',
    '$state ','$zip','$event_date','$venue_city','$venue_name','$vif_date')");
    }
    header("Location: http://www.tantriczen.com/forums/");
    ?>
    As a word of caution, this will work but it doesn't checkto make sure the data was actuall inserted into the database, if there was a problem, the user would be redirected anyway. You should add some error checking.

    PHP Code:
    <?
    mysql_connect
    ("localhost""fan""pword"); 
    mysql_select_db("tantriczen_fanclub"); 

    if(
    $submit) { 
    $query mysql_query("INSERT INTO fans  VALUES('$last_name','$first_name',
    '
    $email_address' ,'$phone_number','$street_address','$your_city',
    '
    $state ','$zip','$event_date','$venue_city','$venue_name','$vif_date')") or DIE(mysql_error());
    if(
    mysql_affected_rows()) {
    header("Location: [url]http://www.tantriczen.com/forums/[/url]");
    }
    else {
    print 
    "there was an error inserting the record.";
    }
    }

    or 
    soemthing like that.

    ?>
    Last edited by freddydoesphp; Dec 31, 2001 at 13:40.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  8. #8
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good idea Freddy. Man, I love error-checking.
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  9. #9
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Colin, you ought change your sig query to

    PHP Code:
    mysql_query("update sitepoints set spts -=1 where user_id NOT IN(11476,11335)"); 
    Much nicer looking don't you think?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  10. #10
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by freddydoesphp
    Maelstrom


    I assume yours didn't work because you tried to implement header() after output had been started in the browser. Headers must precede any output including html code or whitespace.


    Probably. I have a page that reloads itself when the user has done something. After that it goes into some formatting and trys to load a page. I have to use javascript to do this because header() doesn't like the fact that I have a header already defined. Is there a way to clear the header info and then use header()?
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  11. #11
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by freddydoesphp
    Colin, you ought change your sig query to

    PHP Code:
    mysql_query("update sitepoints set spts -=1 where user_id NOT IN(11476,11335)"); 
    Much nicer looking don't you think?
    lol i mentioned that to him a couple months ago. i told hom that his query wouldn't work right. actually, yours won't either. should be:

    PHP Code:
    mysql_query('UPDATE sitepoints SET spts = spts - 1 WHERE userid NOT IN(11476, 11335)'); 
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  12. #12
    SitePoint Enthusiast guz's Avatar
    Join Date
    Dec 2001
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thought that was it but i get this

    Warning: Cannot add header information - headers already sent by (output started at /home/tantric/tantriczen-www/mng/index.php:8) in /home/tantric/tantriczen-www/mng/index.php on line 17

    lets knock thisout okay

  13. #13
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like I said, you cannot have any whitespace or html code before your opening php tag. IN that file and in any included files. Also no PHP can print or echo anything before that point either.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  14. #14
    What? Maelstrom's Avatar
    Join Date
    Oct 2001
    Location
    Whistler BC originally from Guelph Ontario
    Posts
    2,175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by freddydoesphp
    Like I said, you cannot have any whitespace or html code before your opening php tag. IN that file and in any included files. Also no PHP can print or echo anything before that point either.
    so the only way to refresh a page or redirect is to use javascript?
    Maelstrom Personal - Apparition Visions
    Development - PhP || Mysql || Zend || Devshed
    Unix - FreeBSD || FreeBsdForums || Man Pages
    They made me a sitepoint Mentor - Feel free to PM me or Email me and I will see if I can help.

  15. #15
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ?? No, just do your database stuff at the top of the page before evrything else.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •