Redirecting PHP
<p>How would you redirect from a PHP page to another?</p>

<pre><code>&lt;/head&gt;
    &lt;body&gt;
        &lt;!-- Home --&gt;
        &lt;div data-role="page" id="page1"&gt;
            &lt;div data-theme="a" data-role="header"&gt;
            &lt;a data-role="button" data-theme="d" href="login.html" data-icon="arrow-l" data-iconpos="left" class="ui-btn-left"&gt;
                    Back
                &lt;/a&gt;
                &lt;a data-role="button" href="index.html" data-icon="home" data-iconpos="right" data-theme="d"class="ui-btn-right"&gt;
                 Home  
                &lt;/a&gt;
                &lt;h3&gt;
                    Login Process
                &lt;/h3&gt;
            &lt;/div&gt;
            &lt;div data-role="content"&gt;

&lt;?php
// takes the variables from action script and assigns them php variables names
$user = $_POST ['username'];
$pass = $_POST ['password'];

// if there is a user name and password
if ($user &amp;&amp; $pass)
{
    // connect to server
    mysql_connect("localhost", "", "") or die(mysql_error());
    //select database
    mysql_select_db("") or die(mysql_error());

    //Create a query that selects all data from the PATIENT table where the username and password match
    $query = "SELECT * FROM Patient WHERE Username = '$user' AND Password = '$pass'";

    //executes query on the database
    $result = mysql_query ($query) or die ("didn't query");
    //this selects the results as rows

    $num = mysql_num_rows ($result);
    //if there is only 1 result returned than the data is ok 
    if ($num == 1)
    {
        //sends back a data of "Success"
        echo "Successful Login";
        $row=mysql_fetch_array($result);
        $_SESSION['Name'] = $row['Name'];
        $_SESSION['Address'] = $row['Address'];
    }
    else
    {
        //sends back a message of "failed"
        echo "Unsuccessful Login";
    }
}

?&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>So when the user logs in, it takes them to the page shown above. What i need it to do is, if login is successful, I need it to go to redirect to another PHP page.</p>

<p>Thanks in advance!</p>

<p>login.php</p>

<pre><code>        &lt;?php
// takes the variables from action script and assigns them php variables names
$user = $_POST ['username'];
$pass = $_POST ['password'];
$error = '';

// if there is a user name and password
if ($user &amp;&amp; $pass)
{
    // connect to server
    mysql_connect("localhost", "", "") or die(mysql_error());
    //select database
    mysql_select_db("") or die(mysql_error());

    //Create a query that selects all data from the PATIENT table where the username and password match
    $query = "SELECT * FROM Patient WHERE Username = '$user' AND Password = '$pass'";

    //executes query on the database
    $result = mysql_query ($query) or die ("didn't query");
    //this selects the results as rows

    $num = mysql_num_rows ($result);
    //if there is only 1 result returned than the data is ok 
   if ($num == 1)
{
header("Location: http://helios.hud.ac.uk/u101010/PHP/details1.php");
}
        //sends back a data of "Success"
        $return_message =  "Successful Login";
        $row=mysql_fetch_array($result);
        $_SESSION['Name'] = $row['Name'];
        $_SESSION['Address'] = $row['Address'];
    }
    else
    {
        //sends back a message of "failed"
        $return_message = echo "Unsuccessful Login";
    }
}
&lt;html&gt;
    &lt;head&gt;
        &lt;meta charset="utf-8" /&gt;
        &lt;meta name="viewport" content="width=device-width, initial-scale=1" /&gt;
        &lt;meta name="apple-mobile-web-app-capable" content="yes" /&gt;
        &lt;meta name="apple-mobile-web-app-status-bar-style" content="black" /&gt;
        &lt;title&gt;
        &lt;/title&gt;
        &lt;link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.css" /&gt;
        &lt;link rel="stylesheet" href="my.css" /&gt;
        &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;
        &lt;/script&gt;
        &lt;script src="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.js"&gt;
        &lt;/script&gt;
        &lt;script src="my.js"&gt;
        &lt;/script&gt;
        &lt;!-- User-generated css --&gt;
        &lt;style&gt;
        &lt;/style&gt;
        &lt;!-- User-generated js --&gt;
        &lt;script&gt;
            try {

    $(function() {

    });

  } catch (error) {
    console.error("Your javascript has an error: " + error);
  }
        &lt;/script&gt;

?&gt;&lt;/head&gt;
    &lt;body&gt;
        &lt;!-- Home --&gt;
        &lt;div data-role="page" id="page1"&gt;
            &lt;div data-theme="a" data-role="header"&gt;
            &lt;a data-role="button" data-theme="d" href="login.html" data-icon="arrow-l" data-iconpos="left" class="ui-btn-left"&gt;
                    Back
                &lt;/a&gt;
                &lt;a data-role="button" href="index.html" data-icon="home" data-iconpos="right" data-theme="d"class="ui-btn-right"&gt;
                 Home  
                &lt;/a&gt;
                &lt;h3&gt;
                    Login Process
                &lt;/h3&gt;
            &lt;/div&gt;
            &lt;div data-role="content"&gt;

&lt;?php echo $return_message; ?&gt;

            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>Details1.php</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;?php
session_start();
?&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta charset="utf-8" /&gt;
        &lt;meta name="viewport" content="width=device-width, initial-scale=1" /&gt;
        &lt;meta name="apple-mobile-web-app-capable" content="yes" /&gt;
        &lt;meta name="apple-mobile-web-app-status-bar-style" content="black" /&gt;
        &lt;title&gt;
        &lt;/title&gt;
        &lt;link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.css" /&gt;
        &lt;link rel="stylesheet" href="my.css" /&gt;
        &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;
        &lt;/script&gt;
        &lt;script src="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.js"&gt;
        &lt;/script&gt;
        &lt;script src="my.js"&gt;
        &lt;/script&gt;
        &lt;!-- User-generated css --&gt;
        &lt;style&gt;
        &lt;/style&gt;
        &lt;!-- User-generated js --&gt;
        &lt;script&gt;
            try {

    $(function() {

    });

  } catch (error) {
    console.error("Your javascript has an error: " + error);
  }
        &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;!-- Home --&gt;
        &lt;div data-role="page" id="page1"&gt;
            &lt;div data-theme="a" data-role="header"&gt;
            &lt;a data-role="button" data-theme="c" href="menu.html" data-icon="arrow-l" data-iconpos="left" class="ui-btn-left"&gt;
                    Main Menu
                    &lt;/a&gt;
                &lt;h3&gt;
                    Your details
                &lt;/h3&gt;


            &lt;/div&gt;
            &lt;div data-role="content"&gt;
            Name: &lt;?php echo $_SESSION['Name'];?&gt;
            &lt;br /&gt;
            Address: &lt;?php echo $_SESSION['Address'];?&gt;



         &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>details.html</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta charset="utf-8" /&gt;
        &lt;meta name="viewport" content="width=device-width, initial-scale=1" /&gt;
        &lt;meta name="apple-mobile-web-app-capable" content="yes" /&gt;
        &lt;meta name="apple-mobile-web-app-status-bar-style" content="black" /&gt;
        &lt;title&gt;
        &lt;/title&gt;
        &lt;link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.css" /&gt;
        &lt;link rel="stylesheet" href="my.css" /&gt;
        &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;
        &lt;/script&gt;
        &lt;script src="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.js"&gt;
        &lt;/script&gt;
        &lt;script src="my.js"&gt;
        &lt;/script&gt;
        &lt;!-- User-generated css --&gt;
        &lt;style&gt;
        &lt;/style&gt;
        &lt;!-- User-generated js --&gt;
        &lt;script&gt;
            try {

    $(function() {

    });

  } catch (error) {
    console.error("Your javascript has an error: " + error);
  }
        &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;!-- Home --&gt;
        &lt;div data-role="page" id="page1"&gt;
            &lt;div data-theme="a" data-role="header"&gt;
            &lt;a data-role="button" data-theme="c" href="menu.html" data-icon="arrow-l" data-iconpos="left" class="ui-btn-left"&gt;
                    Main Menu
                    &lt;/a&gt;
                &lt;h3&gt;
                    Your details
                &lt;/h3&gt;
            &lt;/div&gt;
           &lt;form name="form1" method="post" action="details1.php"&gt;
            &lt;strong&gt;Details&lt;/strong&gt;
            &lt;br /&gt;
            &lt;br /&gt;
            Name: &lt;input type="text" name"Name" /&gt;
            &lt;br /&gt;
            Address: &lt;input type="text" name="Address"/&gt;
            &lt;br /&gt;
            &lt;input type="submit" name="Submit" value="Book appointment" /&gt;
            &lt;br /&gt;
            &lt;input type="submit" name="Submit" value="Cancel appointment" /&gt;
            &lt;/form&gt; 

               &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>login.html</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta charset="utf-8" /&gt;
        &lt;meta name="viewport" content="width=device-width, initial-scale=1" /&gt;
        &lt;meta name="apple-mobile-web-app-capable" content="yes" /&gt;
        &lt;meta name="apple-mobile-web-app-status-bar-style" content="black" /&gt;
        &lt;title&gt;
        &lt;/title&gt;
        &lt;link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.css" /&gt;
        &lt;link rel="stylesheet" href="my.css" /&gt;
        &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;
        &lt;/script&gt;
        &lt;script src="https://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.js"&gt;
        &lt;/script&gt;
        &lt;script src="my.js"&gt;
        &lt;/script&gt;
        &lt;!-- User-generated css --&gt;
        &lt;style&gt;
        &lt;/style&gt;
        &lt;!-- User-generated js --&gt;
        &lt;script&gt;
            try {

    $(function() {

    });

  } catch (error) {
    console.error("Your javascript has an error: " + error);
  }
        &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;!-- Home --&gt;
        &lt;div data-role="page" id="page1"&gt;
            &lt;div data-theme="a" data-role="header"&gt;
            &lt;a data-role="button" data-theme="d" href="login.html" data-icon="arrow-l" data-iconpos="left" class="ui-btn-left"&gt;
                    Back
                &lt;/a&gt;
                &lt;a data-role="button" href="index.html" data-icon="home" data-iconpos="right" data-theme="d"class="ui-btn-right"&gt;
                 Home  
                &lt;/a&gt;
                &lt;h3&gt;
                    Login
                &lt;/h3&gt;
            &lt;/div&gt;
            &lt;div data-role="content"&gt;
                &lt;h4&gt;
                    Enter login details below:
                &lt;/h4&gt;

              &lt;form name="form1" method="post" action="login.php"&gt;
            &lt;strong&gt;Patient Login &lt;/strong&gt;
            &lt;br /&gt;
            &lt;br /&gt;
            Username: &lt;input name="username" type="text" id="username" /&gt;
            &lt;br /&gt;
            Password: &lt;input name="password" type="password" id="password" /&gt;
            &lt;br /&gt;
            &lt;br /&gt;
            &lt;br /&gt;
            &lt;input type="submit" name="Submit" value="Login" /&gt;
            &lt;/form&gt;
                &lt;br /&gt;
                &lt;div data-role="content"&gt;
                &lt;h4&gt;
                 Please ensure your username and password are kept secure.
                &lt;/h4&gt;

                &lt;br /&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>
