Search the Community
Showing results for tags 'mysql sql variables'.
-
Hello. I wrote based on 2 toturials and my knowledge the following code: <?php session_start(); if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="Login to Bitcoin Double Machine, cancel to sign up"'); header('HTTP/1.0 401 Unauthorized'); //echo 'You canceled the login. Click <a href="test.php">here</a> to retry.'; echo "<script type='text/javascript'> var msg = \"LOGIN CANCELLED. PLEASE REFRESH OR SIGN UP\"; msg = \" ... \" + msg;pos = 0; function scrollTitle() { document.title = msg.substring(pos, msg.length) + msg.substring(0, pos); pos++; if (pos > msg.length) pos = 0 window.setTimeout(\"scrollTitle()\",300); } scrollTitle(); </script>"; echo "<h1>To sign up, use the button below</h1>"; echo "<a href=\"signup.php\" style=\"-webkit-appearance: button;-moz-appearance: button; appearance: button; text-decoration: none; color: initial\">Sign Up</a>"; echo "<br><br>"; echo "<iframe src=\"../401.php\" seamless style=\"width:100%;height:80%\"></iframe>"; exit; } else { define('DB_HOST', 'localhost'); define('DB_NAME', 'dan cojocaru'); define('DB_USER','root'); define('DB_PASSWORD','abcd'); $con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error()); $db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error()); /* //$ID = $_SESSION['user']; //$Password = $_SESSION['pass']; */ function SignIn() { //session_start(); //starting the session for user profile page if(!empty($_SERVER['PHP_AUTH_USER'])) //checking the 'user' name which is from Sign-In.html, is it empty or have some text { $query = mysql_query("SELECT * FROM UserName where userName = " . $_SERVER['PHP_AUTH_USER'] . " AND pass = " . $_SESSION['PHP_AUTH_PW'] . "") or die(mysql_error()); //LINE 38 $row = mysql_fetch_array($query) or die(mysql_error()); if(!empty($row['userName']) AND !empty($row['pass'])) { $_SESSION['userName'] = $row['pass']; echo "SUCCESSFULLY LOGIN TO USER PROFILE PAGE..."; } else { echo "SORRY... YOU ENTERD WRONG ID AND PASSWORD... PLEASE RETRY..."; } } } //if(isset($_POST['submit'])) //{ SignIn(); //} } ?> Commented thing are not used but I never ever delete anything, just in case I might need it. So I saved this code and tested, but I got this error: Notice: Undefined index: PHP_AUTH_PW in C:\xampp\htdocs\test3.php on line 38 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 Please help me to fix this code.