coinmagnate Posted March 7, 2009 Share Posted March 7, 2009 I've got a database set up and my login works but when I try to join with the new member form, I get a line 10 error for my confirm page. I would appreciate it if someone could point out to me what the problem is. I can't figure out what I need to be doing to fix this. Thanks, Here is the link for the join page where the new member form is: http://199.101.8.178/jgeiger/php/join.php and here is the code of my confirm page: <!--#INCLUDE FILE="includes/dbconnection.php"--> <? ob_start(); //turn on output buffering session_start(); //start session variables ini_set('display_errors', 1); //display all errors $Username = $_POST("UserName") //request user entered and validated user name $Password = $_POST("Password") //request user entered and validated password $EMail = $_POST("EMail")//request user entered and validated email address Auth = 1 //security variable set to default of 1 $News = $_POST("news") //initialize your variables, assigning them with the $_POST require ('includes/dbconnection.php');//include the database connection $authorized = false; //set testing variable While not (!$rs->EOF) { //while not at the end of the file continue if ($rs->Fields["UserName"]->Value=="$username" && $rs->Fields["Password"]->Value=="$password") { $_SESSION['auth'] = $rs->Fields['Auth']->Value; $_SESSION['username'] = $rs->Fields['UserName']->Value; $authorized = true; } $rs->MoveNext(); } if (!$authorized) { header('Location: logininvalid.php'); $ob_end_flush(); exit();} else { header('Location: index.php'); $ob_end_flush(); exit(); } //check for duplicate names, redirect to user taken page, otherwise keep going, check authorize.php code for the code to do this strSQL = "INSERT INTO Login (UserName, Password, EMail, Auth, News)"&_ "VALUES ( '" & UserName & "' , '" & Password & "' , '" & EMail & "', '" & Auth & "', '" & News & "')" set objRS = conn.Execute(strSQL)//your sql statement goes here to insert the values //execute SQL statement $session("username") = session("tUserName")//assign username variable $session("auth") = 1//assign auth value for security require ('index.php');//redirect user to index.php page //close the connection $rs->Close(); $conn->Close(); $rs = null; $conn = null; $ob_end_flush(); ?> Link to comment https://forums.phpfreaks.com/topic/148364-new-member-joining-confirm-page-doesnt-work/ Share on other sites More sharing options...
kickstart Posted March 7, 2009 Share Posted March 7, 2009 Hi You have a load of missing semi colons at the end of the assignment lines (eg $Username = $_POST("UserName"); //request user entered and validated user name). All the best Keith Link to comment https://forums.phpfreaks.com/topic/148364-new-member-joining-confirm-page-doesnt-work/#findComment-778910 Share on other sites More sharing options...
coinmagnate Posted March 7, 2009 Author Share Posted March 7, 2009 Thanks. I added semi colons and now the error says it is a line 12 error. I don't see anything different on line 12 than on the other lines. What else do I need to fix to get it to work? Here's my new code for the confirm page: <!--#INCLUDE FILE="includes/dbconnection.php"--> <? ob_start(); //turn on output buffering session_start(); //start session variables ini_set('display_errors', 1); //display all errors $Username = $_POST("UserName"); //request user entered and validated user name $Password = $_POST("Password"); //request user entered and validated password $EMail = $_POST("EMail"); //request user entered and validated email address Auth = 1: //security variable set to default of 1 $News = $_POST("news"); //initialize your variables, assigning them with the $_POST require ('includes/dbconnection.php');//include the database connection $authorized = false; //set testing variable While not (!$rs->EOF) {; //while not at the end of the file continue if ($rs->Fields["UserName"]->Value=="$username" && $rs->Fields["Password"]->Value=="$password") {; $_SESSION['auth'] = $rs->Fields['Auth']->Value; $_SESSION['username'] = $rs->Fields['UserName']->Value; $authorized = true; } $rs->MoveNext(); } if (!$authorized) {; header('Location: logininvalid.php'); $ob_end_flush(); exit();} else {; header('Location: index.php'); $ob_end_flush(); exit(); } //check for duplicate names, redirect to user taken page, otherwise keep going, check authorize.php code for the code to do this strSQL = "INSERT INTO Login (UserName, Password, EMail, Auth, News)"&_ "VALUES ( '" & UserName & "' , '" & Password & "' , '" & EMail & "', '" & Auth & "', '" & News & "')" set objRS = conn.Execute(strSQL); //your sql statement goes here to insert the values //execute SQL statement $session("username") = session("tUserName"); //assign username variable $session("auth") = 1; //assign auth value for security require ('index.php');//redirect user to index.php page //close the connection $rs->Close(); $conn->Close(); $rs = null; $conn = null; $ob_end_flush(); ?> Link to comment https://forums.phpfreaks.com/topic/148364-new-member-joining-confirm-page-doesnt-work/#findComment-778923 Share on other sites More sharing options...
v3nom Posted March 7, 2009 Share Posted March 7, 2009 Auth = 1: //security variable set to default of 1 If the comment is correct, and this is a variable, then it should be: $auth = 1; Careful of the colon at the end there - should be a semi-colon. Link to comment https://forums.phpfreaks.com/topic/148364-new-member-joining-confirm-page-doesnt-work/#findComment-779044 Share on other sites More sharing options...
kickstart Posted March 8, 2009 Share Posted March 8, 2009 Hi This bit looks like VB, not PHP. strSQL = "INSERT INTO Login (UserName, Password, EMail, Auth, News)"&_ "VALUES ( '" & UserName & "' , '" & Password & "' , '" & EMail & "', '" & Auth & "', '" & News & "')" set objRS = conn.Execute(strSQL); //your sql statement goes here to insert the values All the best Keith Link to comment https://forums.phpfreaks.com/topic/148364-new-member-joining-confirm-page-doesnt-work/#findComment-779217 Share on other sites More sharing options...
coinmagnate Posted March 8, 2009 Author Share Posted March 8, 2009 You are correct. I worked the code until the errors got down to these lines but I'm not sure what the correct syntax for php is for this bit of code. My whole project started out as a web site written in ASP with VB code and then we had to take the same site and change it to PHP. I've got everything else working but this last little bit. I really appreciate all the help. I've put dollar signs at the beginning of these lines and semicolons at the end but that's not working. What would you suggest? Link to comment https://forums.phpfreaks.com/topic/148364-new-member-joining-confirm-page-doesnt-work/#findComment-779226 Share on other sites More sharing options...
v3nom Posted March 8, 2009 Share Posted March 8, 2009 Change the VB to PHP, to make everything uniform. Link to comment https://forums.phpfreaks.com/topic/148364-new-member-joining-confirm-page-doesnt-work/#findComment-779257 Share on other sites More sharing options...
kickstart Posted March 8, 2009 Share Posted March 8, 2009 Hi I have had a play and think this is more towards what you want. <!--#INCLUDE FILE="includes/dbconnection.php"--> <? ob_start(); //turn on output buffering session_start(); //start session variables ini_set('display_errors', 1); //display all errors $Username = $_POST("UserName"); //request user entered and validated user name $Password = $_POST("Password"); //request user entered and validated password $EMail = $_POST("EMail"); //request user entered and validated email address $Auth = 1; //security variable set to default of 1 $News = $_POST("news"); //initialize your variables, assigning them with the $_POST require ('includes/dbconnection.php');//include the database connection $authorized = false; //set testing variable $sSql = "SELECT UserName, Password, Auth FROM users WHERE UserName = '$username' AND Password = '$password'"; if ( !($result = mysql_query($sSql)) ) { print('Error '.$sSql); die; } else { if( $row = mysql_fetch_assoc($result) ) { //while not at the end of the file continue if ($row["UserName"]==$username && $row["Password"]==$password) { $_SESSION['auth'] = $row['Auth']; $_SESSION['username'] = $row['UserName']; $authorized = true; } } } if (!$authorized) { header('Location: logininvalid.php'); $ob_end_flush(); exit(); } else { header('Location: index.php'); $ob_end_flush(); exit(); } //check for duplicate names, redirect to user taken page, otherwise keep going, check authorize.php code for the code to do this $sSql = "INSERT INTO Login (UserName, Password, EMail, Auth, News) VALUES ( '$UserName' , '$Password' , '$EMail', '$Auth', '$News')" //execute SQL statement if ( !($result = mysql_query($sSql)) ) { print('Error '.$sSql); die; } $session["username"] = $_SESSION["UserName"]; //assign username variable $session["auth"] = 1; //assign auth value for security require ('index.php');//redirect user to index.php page $ob_end_flush(); ?> However I presume that this is just a fragment of the code, but I have put a bit of SQL in to do the SELECT that didn't appear to be there. There is also the issue that the code at the end would never be executed (including the INSERT), as just before it there is an IF statement that does a header in both outcomes, which would cause execution to be transferred to logininvalid.php or index.php (although this would fail as you have a blank line at the top of the script, so it would have sent a blank line to the browser already which would prevent the header from working). All the best Keith Link to comment https://forums.phpfreaks.com/topic/148364-new-member-joining-confirm-page-doesnt-work/#findComment-779483 Share on other sites More sharing options...
coinmagnate Posted March 8, 2009 Author Share Posted March 8, 2009 Actually this is the whole code. This is the code from the confirm page that checks the database for duplicate username, writes the new username if acceptable to the database, and redirects the user to the member only area. My syntax is all wrong because I'm trying to convert VB to PHP but since I'm totally new to PHP, I'm having a bit of a problem. I deleted the empty lines at the top and inserted your code. I got these errors: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Inetpub\ftproot\class\LocalUser\jgeiger\php\confirm.php:2) in C:\Inetpub\ftproot\class\LocalUser\jgeiger\php\confirm.php on line 3 Notice: Array to string conversion in C:\Inetpub\ftproot\class\LocalUser\jgeiger\php\confirm.php on line 7 Fatal error: Call to undefined function: array() in C:\Inetpub\ftproot\class\LocalUser\jgeiger\php\confirm.php on line 7 I don't understand any of these errors. Especially the header error since there is no header script at the top of the code. Thanks for all your help, Janet Link to comment https://forums.phpfreaks.com/topic/148364-new-member-joining-confirm-page-doesnt-work/#findComment-779575 Share on other sites More sharing options...
kickstart Posted March 8, 2009 Share Posted March 8, 2009 Hi The header error is the one to expect if there is anything before your php code. Possibly including the commented out include . I think the array error is due to using normal brackets rather than square brackets for the $_POST variables (sorry, I should have spotted that earlier) $Username = $_POST["UserName"]; //request user entered and validated user name $Password = $_POST["Password"]; //request user entered and validated password $EMail = $_POST["EMail"]; //request user entered and validated email address $Auth = 1; //security variable set to default of 1 $News = $_POST["news"]; //initialize your variables, assigning them with the $_POST All the best Keith Link to comment https://forums.phpfreaks.com/topic/148364-new-member-joining-confirm-page-doesnt-work/#findComment-779584 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.