Jump to content

Login Form Help


slj90

Recommended Posts

Hello, I am trying to make a login form,

 

I have a login form page and an action page, here is the code from the action page:

 

<?php
include "connection2.php"; 	 
?>

<?php
session_start();
// Collect data from form and save in variables
//See if any info was submitted 
$Username = $_GET['Username'];  
//Clean data - trim space 
$Username = trim ( $Username);  
//Check its ok - if not then add an error message to the error string 
if (empty($Username))  
    $errorString = $errorString."<br>Please supply Username.";
//See if any info was submitted 
$Password = $_GET['Password'];  
//Clean data - trim space 
$Password = trim ( $Password);  
//Check its ok - if not then add an error message to the error string 
if (empty($Password))  
    $errorString = $errorString."<br>Please supply Password.";        

//  Query to search the user table
$query= "SELECT * FROM Users WHERE Username='$Username' AND  Password='$Password'"

// Run query through connection
	$result = mysql_query ($query); 

// Check result of query 

// if rows found set authenticated user to the user name entered 
if (mysql_num_rows($result) > 0) { 
$_SESSION["authenticatedUser"] = $Username;
// Relocate to the logged-in page
header("Location: loggedon.php");
} 
else
// login failed redirect back to login page with error message
{
$_SESSION["message"] = "Could not connect as $Username " ;
header("Location: login.php");
}
?>

 

At the moment, I get the error 'syntax error, unexpected T_VARIABLE' on line 27

 

($result = mysql_query ($query); )

 

 

Can you see anything wrong?

 

Thank you for your help

 

Link to comment
https://forums.phpfreaks.com/topic/184746-login-form-help/
Share on other sites

Thanks alot!

 

That has got rid of that error but now I have the following...

 

 

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at H:\xampp\xampp\htdocs\loginAction.php:5) in H:\xampp\xampp\htdocs\loginAction.php on line 6

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at H:\xampp\xampp\htdocs\loginAction.php:5) in H:\xampp\xampp\htdocs\loginAction.php on line 6

 

Warning: Cannot modify header information - headers already sent by (output started at H:\xampp\xampp\htdocs\loginAction.php:5) in H:\xampp\xampp\htdocs\loginAction.php on line 35

 

Any suggestions  :shy: ?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/184746-login-form-help/#findComment-975282
Share on other sites

connection2.php only contains the following code...

 

<?php
$connection = mysql_connect("localhost", "root") or die(mysql_error());
mysql_select_db("users", $connection) or die(mysql_error());
?>

 

 

so i don't think that's the problem?

 

any other ideas?

 

your help is much appreciated!

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/184746-login-form-help/#findComment-975287
Share on other sites

put your session_start over there. and remove it from all the other files you've put it in

 

<?php
   session_start();
   $connection = mysql_connect("localhost", "root") or die(mysql_error());
   mysql_select_db("users", $connection) or die(mysql_error());
?>

Link to comment
https://forums.phpfreaks.com/topic/184746-login-form-help/#findComment-975290
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.