
andy_b_1502
Members-
Posts
397 -
Joined
-
Last visited
Everything posted by andy_b_1502
-
Thank you, when logging in a fake user (Mary) i get error message: Hello mary Warning: Cannot modify header information - headers already sent by (output started at /hermes/bosweb25a/b109/ipg.removalspacecom/check_login2.php:9) in /hermes/bosweb25a/b109/ipg.removalspacecom/check_login2.php on line 31 Aslo what would i have to change to fit this code into my desgined page rather than a blank white page?
-
I think i need to go back to square one with this? Here is whats at the top of my pages that i want the log-in check to do and display the username if there logged in: <?php session_start(); include("check_login2.php"); echo ("message!!!"); ?> and this is "check_login2.php with the suggested new $rs if statment: <?php if(isset($_POST['submit'])){ //check for submit button click $username = $_POST['myusername']; $password = $_POST['mypassword']; // proceed with rest of code $self = $_SERVER['PHP_SELF']; $referer = $_SERVER['HTTP_REFERER']; #if either form field is empty return to the log-in page if( (!$username ) or (!$password ) ) { header( "Location:$referer" ); exit(); } #connect to mysql $conn = @mysql_connect( "server", "username", "password" ) or die( "Could not connect" ); #select database $rs = @mysql_select_db( "removalspacelogin", $conn ) or die ( "Could not select db" ); #create query $sql="select * from users where username = '$username' and upassword = '$password'"; #execute query $rs = mysql_query( $sql, $conn ) or die( mysql_error() ); if($rs){ $_SESSION['username'] = $username;} #get number of rows that match username and password $num = mysql_numrows( $rs ); #if there is a match the log-in is done if( $num != 0 ) { header( "Location:login_success.php" ); } else #or return to: login.php { header( "Location:$referer" ); exit(); } } ?> <?php ini_set("display_errors","ON"); ?> <html> <head><title>Check-login</title></head> <body> <?php echo( $msg ); ?> </body> </html> im getting error messages with these in browser: Warning: session_start() [function.session-start]: open(/home/users/web/b109/ipg.removalspacecom/cgi-bin/tmp/sess_11060ed30d8458b614a7263f3d65fb48, O_RDWR) failed: No such file or directory (2) in /hermes/bosweb25a/b109/ipg.removalspacecom/advertise.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /hermes/bosweb25a/b109/ipg.removalspacecom/advertise.php:2) in /hermes/bosweb25a/b109/ipg.removalspacecom/advertise.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /hermes/bosweb25a/b109/ipg.removalspacecom/advertise.php:2) in /hermes/bosweb25a/b109/ipg.removalspacecom/advertise.php on line 2 message!!!
-
<?php session_start(include('db.php' 'login.php')); ?> error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in *** on line 2
-
When using <?php session_start(); include(db.php login.php) ?> I get: "Parse error: syntax error, unexpected T_STRING in /hermes/bosweb25a/b109/ipg.removalspacecom/advertise.php on line 3" With out the in include i get: Warning: session_start() [function.session-start]: open(/home/users/web/b109/ipg.removalspacecom/cgi-bin/tmp/sess_01d911f0daf2192c48ae1f477c853e07, O_RDWR) failed: No such file or directory (2) in /hermes/bosweb25a/b109/ipg.removalspacecom/advertise.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /hermes/bosweb25a/b109/ipg.removalspacecom/advertise.php:2) in /hermes/bosweb25a/b109/ipg.removalspacecom/advertise.php on line 2 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /hermes/bosweb25a/b109/ipg.removalspacecom/advertise.php:2) in /hermes/bosweb25a/b109/ipg.removalspacecom/advertise.php on line 2 Although this is displayed on top of my website page?
-
Thanks, and then put: session start () at the top of every page that i need their username to be displayed?
-
Thanks, where does that if statement go?
-
I would like to know how to take details of my 'users' table from mysql database and check if that user is logged in using cookies or sessions somehow and have that users username displayed on my site, something like: user logged in as: (username), how is this done? What would you guys need to see in order for you to help me? im guessing the login and register scripts which are below, if you need anymore let me know, thanks. Login script: <?php if(isset($_POST['submit'])){ //check for submit button click $username = $_POST['myusername']; $password = $_POST['mypassword']; // proceed with rest of code $self = $_SERVER['PHP_SELF']; $referer = $_SERVER['HTTP_REFERER']; #if either form field is empty return to the log-in page if( (!$username ) or (!$password ) ) { header( "Location:$referer" ); exit(); } #connect to mysql $conn = @mysql_connect( "myserver", "username", "password" ) or die( "Could not connect" ); #select database $rs = @mysql_select_db( "removalspacelogin", $conn ) or die ( "Could not select db" ); #create query $sql="select * from users where username = '$username' and upassword = '$password'"; #execute query $rs = mysql_query( $sql, $conn ) or die( mysql_error() ); #get number of rows that match username and password $num = mysql_numrows( $rs ); #if there is a match the log-in is done if( $num != 0 ) { header( "Location:login_success.php" ); } else #or return to: login.php { header( "Location:$referer" ); exit(); } } ?> <?php ini_set("display_errors","ON"); ?> <html> <head><title>Check-login</title></head> <body> <?php echo( $msg ); ?> </body> </html> Register users script: <?PHP $user_name = "removalspace"; $password = "123"; $database = "removalspacelogin"; $server = "removalspacecom.ipagemysql.com"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "INSERT INTO users (username, upassword, email) VALUES ('" .$username. "', '" .$upassword. "', '" .$email. "')"; $result = mysql_query($SQL); header( 'Location: http://www.removalspace.com/index.php' ); exit(); } else { print "Database NOT Found "; mysql_close($db_handle); } ?>
-
Thank you so much for your help! that works PERFECTLY.
-
Even now its changed like so: <?php if(isset($_POST['submit'])){ //check for submit button click $username = $_POST['myusername']; $password = $_POST['mypassword']; // proceed with rest of code $self = $_SERVER['PHP_SELF']; $referer = $_SERVER['HTTP_REFERER']; #if either form field is empty return to the log-in page if( (!$username ) or (!$password ) ) { header( "Location:$referer" ); exit(); } #connect to mysql $conn = @mysql_connect( "removalspacecom.ipagemysql.com", "removalspace", "123" ) or die( "Could not connect" ); #select database $rs = @mysql_select_db( "removalspacelogin", $conn ) or die ( "Could not select db" ); #create query $sql="select * from users where username = '$username' and upassword = '$password')"; #execute query $rs = mysql_query( $sql, $conn ) or die( mysql_error() ); #get number of rows that match username and password $num = mysql_numrows( $rs ); #if there is a match the log-in is done if( $num != 0 ) { $msg = "Welcome $username - your log-in was successful!"; } else #or return to: login.php { header( "Location:$referer" ); exit(); } } ?> <?php ini_set("display_errors","ON"); ?> <html> <head><title>Check-login</title></head> <body> <?php echo( $msg ); ?> </body> </html> i still get error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 whats causing this??
-
upassword is the name of my column in mysql phpmyadmin, i cnaged the $upassword to $password but still get the same result: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
-
upassword is the name of my coloumn in mysql phpmyadmin, should i still change this to $password?
-
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 line 1?: <?php if(isset($_POST['submit'])){ //check for submit button click $username = $_POST['myusername']; $password = $_POST['mypassword']; // proceed with rest of code $self = $_SERVER['PHP_SELF']; $referer = $_SERVER['HTTP_REFERER']; #if either form field is empty return to the log-in page if( (!$username ) or (!$password ) ) { header( "Location:$referer" ); exit(); } #connect to mysql $conn = @mysql_connect( "removalspacecom.ipagemysql.com", "removalspace", "123" ) or die( "Could not connect" ); #select database $rs = @mysql_select_db( "removalspacelogin", $conn ) or die ( "Could not select db" ); #create query $sql="select * from users where username = '$username' and password = '$upassword')"; #execute query $rs = mysql_query( $sql, $conn ) or die( mysql_error() ); #get number of rows that match username and password $num = mysql_numrows( $rs ); #if there is a match the log-in is done if( $num != 0 ) { $msg = "Welcome $username - your log-in was successful!"; } else #or return to: login.php { header( "Location:$referer" ); exit(); } } ?> <?php ini_set("display_errors","ON"); ?> <html> <head><title>Check-login</title></head> <body> <?php echo( $msg ); ?> </body> </html>
-
Changed the Submit to submit. Turned on error reporting to get: Could not execute query in browser when button is clicked?
-
:'( ive actually been trying to suss this out for about two months, the original script before i was kindly helped to modify, was from "php5 in easy steps" im regretting buying it now?....
-
Okay ive tried that and all it does when i click the submit button is display a white page? Im new to php and need dummy style help with this. With your suggestions my code looks like this: <?php if(isset($_POST['submit'])){ //check for submit button click $username = $_POST['myusername']; $password = $_POST['mypassword']; // proceed with rest of code $self = $_SERVER['PHP_SELF']; $referer = $_SERVER['HTTP_REFERER']; #if either form field is empty return to the log-in page if( (!$username ) or (!$password ) ) { header( "Location:$referer" ); exit(); } #connect to mysql $conn = @mysql_connect( "", "", "123" ) or die( "Could not connect" ); #select database $rs = @mysql_select_db( "removalspacelogin", $conn ) or die ( "Could not select db" ); #create query $sql="select * from users where username = '$username' and password = '$password')"; #execute query $rs = mysql_query( $sql, $conn ) or die( "Could not execute query" ); #get number of rows that match username and password $num = mysql_numrows( $rs ); #if there is a match the log-in is done if( $num != 0 ) { $msg = "Welcome $username - your log-in was successful!"; } else #or return to: login.php { header( "Location:$referer" ); exit(); } } ?> I really appreciate your help so far. Just finding it hard to grasp.
-
Thanks, so it now looks like so... <?php if(isset($_POST['submit'])){ //check for submit button click $username = $_POST['myusername']; $password = $_POST['mypassword']; // proceed with rest of code} #if either form field is empty return to the log-in page if( (!$username ) or (!$password ) ) { header( "Location:$referer" ); exit(); } #connect to mysql $conn = @mysql_connect( "", "", "123" ) or die( "Could not connect" ); #select database $rs = @mysql_select_db( "removalspacelogin", $conn ) or die ( "Could not select db" ); #create query $sql="select * from users where username = '$username' and password = '$password')"; #execute query $rs = mysql_query( $sql, $conn ) or die( "Could not execute query" ); #get number of rows that match username and password $num = mysql_numrows( $rs ); #if there is a match the log-in is done if( $num != 0 ) { $msg = "Welcome $username - your log-in was successful!"; } else #or return to: login.php { header( "Location:$referer" ); exit(); } ?> <html> <head><title>Check-login</title></head> <body> <?php echo( $msg ); ?> </body> </html> This gives me the parse error: Parse error: syntax error, unexpected $end in /hermes/bosweb25a/b109/ipg.removalspacecom/check_login2.php on line 38 What have i done wrong?
-
This is the form that has the defective submit button? <form name="form1" method="post" action="check_login2.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><span class="style7"><strong>Member Login </strong></span></td> </tr> <tr> <td width="78"><span class="style7">Username</span></td> <td width="6"><span class="style7">:</span></td> <td width="294"><input name="myusername" type="text" class="style7" id="myusername"></td> </tr> <tr> <td><span class="style7">Password</span></td> <td><span class="style7">:</span></td> <td><input name="mypassword" type="password" class="style7" id="mypassword"></td> </tr> <tr> <td><span class="style7"></span></td> <td><span class="style7"></span></td> <td><input name="Submit" type="submit" class="style7" value="Login" /></td> </tr> </table> </td> </form>
-
Hi, i need some help with my script to take data from mysql database to be used for a login. Created table, with registration, checked passwords and such but the login button when clicked does nothing? please help <?php $username = $_POST['username']; $password = $_POST['upassword']; $self = $_SERVER['PHP_SELF']; $referer = $_SERVER['HTTP_REFERER']; #if either form field is empty return to the log-in page if( (!$username ) or (!$password ) ) { header( "Location:$referer" ); exit(); } #connect to mysql $conn = @mysql_connect( "server", "username", "password ) or die( "Could not connect" ); #select database $rs = @mysql_select_db( "removalspacelogin", $conn ) or die ( "Could not select db" ); #create query $sql="select * from users where username=\"$username\" and password = password( \$password\" )"; #execute query $rs = mysql_query( $sql, $conn ) or die( "Could not execute query" ); #get number of rows that match username and password $num = mysql_numrows( $rs ); #if there is a match the log-in in done if( $num != 0 ) { $msg = "Welcome $username - your log-in was successfull!"; } else #or return to: login.php { header( "Location:www.removalspace.com/wrong.html" ); exit(); } ?> <html> <head><title>Check-login</title></head> <body> <?php echo( $msg ); ?> </body> </html>
-
Hi, ive been looking all over for a script to send an email once users on my site register their details, is this possible? all i want is it to send their username and password. Also the same sort of thing is needed for the "lost password" button? Any help suggested would be great, many thanks. Web Form/Registration: <form action="sendAd.php" method="post"> <h4 class="style7">Type of company (Removal, Transport, Storage, Insurance, Local Area or Other):<br /> <input type="text" name="type"/> <br />Company name:<br /> <input type="text" name="company_name"/> <br /> Location:<br /> <input type="text" name="location"/> <br /> Six bullet point description of your company:<br /> <textarea rows="6" cols="21" name="description" ></textarea> </h4> <h4 class="style7"> <br /> <input name="submit" type="submit" id="submit" value="List your ad" /> </h4> <p> </p> </form> SendAd.php: <?PHP $user_name = ""; $password = ""; $database = "removal2"; $server = "server"; $db_handle = mysql_connect($server, $user_name, $password); $db_found = mysql_select_db($database, $db_handle); if ($db_found) { $SQL = "INSERT INTO ads (type, company_name, location, description) VALUES ('" .$type. "', '" .$company_name. "', '" .$location. "', '" .$description. "')"; $result = mysql_query($SQL); mysql_close($db_handle); header( 'Location: http://www.removalspace.com/advert-confirm.php' ); exit(); } else { print "Database NOT Found "; mysql_close($db_handle); } ?> MOD EDIT: code tags added.
-
Any ideas why the form fails to run the script from the submit button? <html><head><title>Log-in Page</title></head> <body> Please enter your user details to log-in here... <form action = "loginscript.php" method = "post"> <p>Username:<br /> <input type = "text" name = "username" /> <br /> <br /> Password:<br /> <input type = "text" name = "password" /> <br /> <br /> <input type = "submit" value = "Log In" /> </p> <p> </p> <p><a href="index.php">back home... </a></p> </form> </body></html>
-
Hi guys new to this site and need some help. Im using PHP 5 in easy steps by Mike McGrath, currently creating the register and login scripts for my website. Ive manged to do the register script fine, it drops new user details into the MySQL database fine, however the login script gives the following error when loggin in: Parse error: syntax error, unexpected T_VARIABLE in /hermes/bosweb25a/b109/ipg.removalspacecom/removal space.com/loginscript.php on line 15 I copied the script word-for-word, letter-for-letter, checked and re-checked. I would like to ask you guys if you see something i dont? Here is the script: <?php $username = $_POST['username']; $password = $_POST['password']; $self = $_SERVER['PHP_SELF']; $referer = $_SERVER['HTTP_REFERER']; #if either form field is empty return to the log-in page if( ( !$username ) or (!$paswword ) ) { header( "Location:$referer" ); exit(); } #connect to MySQL $conn = @mysql_connect ( "removalspacecom.ipagemysql.com", "removal", "123" ) or die("Could not connect" ); #select the specified database $rs = @mysql_select_db( "removal1", $conn ) or die( "Could not select database" ) #create sql query $sql="select * from users where user_name=\"$username\" and password = password( \"$password\" )"; #execute query $rs = myslq_query( $sql, $conn ) or die( "Could not execute query" ); #get number of rows that match username and password $num = mysql_numrows( $rs ); #if there is a match the log-in is authenticated if( $num != 0 ) { $msg = "Welcome $username - your log-in was sucessfull!"; } else #or return to the log-in page { header( "location:$referer" ); exit(); } ?> <html> <head><title>Log-in Authenticated</title></head> <body> <?php echo( $msg ); ?> </body> </html> the error is coming from line 15, the sql query line? why would there be an error from the advisory book? please help me as im stuck on this one. Thanks a lot for any help i get. MOD EDIT: code tags added.