SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: Redirect User

  1. #1
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirect User

    Hi guys .
    I have the following code, how can i redirect the user to message.php
    after submitting the form or page.
    PHP Code:
    <?php
    //ob_start();
      
    include('../common/adm_inc_commons.php');
        
    $sql="select * from m_user where nruser = $nruser";
        
    $result mysql_query($sql) or err_handler();
         
    $row mysql_fetch_object($result);
         
    $nmname=$row->nmname;
         
    $nmpass=$row->nmpassword;
         
    $nmlogin=$row->nmlogin;
         
    $nric=$row->nric;
         
    $nmemail=$row->nmemail;
    //******************************************************************************
      
    $sql1="select * from m_parent_child where nruser=$nruser";
      
    $result_listmysql_query($sql1) or err_handler();
      
    $row mysql_fetch_array($result);
      
    $childarray=$row->nruser_child;
      
    //*********************************************************************************************
      
    $sql="select * from m_user where nruser='$childarray' and cdcat='2'";
                 
    $result_childmysql_query($sql) or mysql_error();
                 
    $row_child mysql_fetch_array($result_child);
                 
    $name=$row_child->nmname;
                 
    $login=$row_child->nmlogin;
                 
    $pass=$row_child->nmpassword;
    //********************************************************************************************
    if (isset($_POST['btnsave_x'])) {
      
    $email =htmlentities($_POST['nmemail']);
      
    $msg =($_POST['message']);
      
    $subject =htmlentities($_POST['subject']);
         
    $headers 'From: Straight-As Team <support@straight-a.com>' "\r\n" .
        
    'Cc: xxxxx@yahoo.com' "\r\n" .
        
    'X-Mailer: PHP/' phpversion() ."\r\n".
        
    'MIME-Version: 1.0' "\r\n" .
        
    'Content-type: text/html; charset=iso-8859-1' "\r\n";
        
    $message "
    Dear valued subscriber,<br>
    Welcome to Straight-As Program.<br>
    Thank you for showing interest in Straight-As program.<br><br>

        "
    .$msg."
    <br>
    Kindly keep the above information for future references.<br>

    For further information please contact:<br>
    support@straight-a.com.<br>

    Best regards,<br>
    Straight-As Team.
    "
    ;

     
    $mail=mail($email,$subject,$message,$headers);
     }
     
    // If (!$mail'){header("Location:message.php");}//else {header("Location:message.php");}
    // header("Location:message.php");
     
    ?>

    <html>
    <head>
    <title>Straight-As:Customer</title>
    </head>
    <?php  include('../common/adm_inc_top.php'); ?>

    <body>
    <?PHP include('adm_cus_send_pass_form.php')?>
    </body>

    </html>

  2. #2
    SitePoint Zealot Bill Palmer's Avatar
    Join Date
    Oct 2005
    Location
    London, UK
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seems like you were on the right track:

    PHP Code:

    if(!$mail) {
        
    header("Location: http://yoursite.com/message.php");

    The HTTP Location header needs the FULL URL to redirect to.

    Good luck.

  3. #3
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Bill Palmer View Post
    The HTTP Location header needs the FULL URL to redirect to.
    You can easily use relative paths:
    PHP Code:
    header("Location.index.php"); 

  4. #4
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys
    i try as u see in my code i comment that header
    bcoz when i try to use like that it throw the message before
    giving me the page to write email to user.
    It mean that when i click the link to that user it directly give me message.
    Not giving me the page to edit or write some message to user(In case of
    header using there).
    I hope u people will get it.
    What i want.

  5. #5
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can easily use relative paths:
    Only as long as your browser uses HTTP 1.0 . HTTP 1.1 requires absolute URI.

  6. #6
    SitePoint Guru mmarif4u's Avatar
    Join Date
    Dec 2006
    Location
    /dev/swat
    Posts
    619
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys i got idea i use it inside the mail function and working.

    PHP Code:
    header ('location:message.php'); 
    the problem was not that its working or not.
    The problem was where to put this header in the code to work properly.

    Thanks guys...

  7. #7
    SitePoint Wizard REMIYA's Avatar
    Join Date
    May 2005
    Posts
    1,351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if(mail(...,...,...)==true){
        
    header("Location:success.php");
    }else{
        
    header("Location:error.php")

    Hope it helps

  8. #8
    SitePoint Zealot Bill Palmer's Avatar
    Join Date
    Oct 2005
    Location
    London, UK
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kailash Badu View Post
    Only as long as your browser uses HTTP 1.0 . HTTP 1.1 requires absolute URI.
    Thanks for the link.

    I knew that absolute URIs were required, but I never saw the spec for it.


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
  •