2 Replies - 270 Views - Last Post: 27 March 2014 - 08:41 PM Rate Topic: -----

#1 waheedmohd1989  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 11-March 14

On click redirect to another page

Posted 13 March 2014 - 08:33 AM

The problem with the code is on clicking submit button it is redirecting to another page. but my task is to redirect to another page after successful login
<?php 
$username = $_POST['username']; 
$password = $_POST['password']; 
if($_POST) { 
if($username=="fred" && $password=="bloggs")
{
$output = 'login successful'.'<link href="http://www.google.com>';
echo $output;
}
else
{
	$error = "must enter username and passowrd";
	echo $error;
}


 //Put code here to execute only when form is submitted 
 session_start(); 
} 
?> 
<!DOCTYPE html> 
<html lang="en"> 
<head> 
 <title>Fred Bloggs Log In</title> 
 <meta charset="utf-8"> 
</head> 
<body> 
<section> 
 <form action="http://fcet7.staffs.ac.uk/m033163b/week4-task3.php" method="post"> 
 <fieldset> 
 <legend>Log in</legend> 
 <p> 
 <label>Username <input type="text" name="username"> 
 </label> 
 </p> 
 
 <p> 
 <label>Password <input type="password" name="password"> 
 </label> 
 </p> <br>
 <input type="submit" name="but1" onclick="" />
 </fieldset>
 </form>
 </section>
 <?php  
 //echo $output;
 //echo $error;
 ?>
 </body>
 </html>



Is This A Good Question/Topic? 0
  • +

Replies To: On click redirect to another page

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9258
  • View blog
  • Posts: 34,735
  • Joined: 12-June 08

Re: On click redirect to another page

Posted 13 March 2014 - 08:40 AM

So like the http_redirect?
Was This Post Helpful? 0
  • +
  • -

#3 Ambitious  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 133
  • Joined: 08-May 13

Re: On click redirect to another page

Posted 27 March 2014 - 08:41 PM

Remove the "action" but keep "method".
<form action="http://fcet7.staffs.ac.uk/m033163b/week4-task3.php" method="post"> 



Then add
header('Location: http://fcet7.staffs.ac.uk/m033163b/week4-task3.php');


after the successful login code.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1