Jump to content

dancojocaru2000

Members
  • Posts

    19
  • Joined

  • Last visited

Everything posted by dancojocaru2000

  1. So you say that I should make something like $value = $_POST['mail']
  2. I want to make an email form using PHP. Everything is good, BUT Is there a way to make a drop-down list and if the visitor selects Admin, email will be sent to admin@$_SERVER[DOCUMENTROOT] and if it selects Postmaster it will be sent to postmaster@<that thing>?
  3. In Access 2013 (or 2016 Preview) it is called Long text. Is there a SQL command that shows it? (There is a almost hidden SQL command processor in Access)
  4. In Access 2013 (or 2016 Preview) it is called Long text
  5. I added it using MS Access. I don't know anything else... Is there a way to make the php script to add automatically the spaces needed to reach 20 characters?
  6. I really don't even know. But how am I supposed to do here. Because if I set the database pass field to only 9 characters... Just tell me please how to make this show TRUE.
  7. I'm completely messed up. I solved that error by gettion SQL to select only by the username and then if the passwords are the same (database and entered) it will do the rest. It looks like this: $sql = "SELECT * FROM Login WHERE Username = '" . $_SERVER['PHP_AUTH_USER'] . "'"; if($result) { while ($row = $result->fetch()) { echo $row['Password']; echo $_SERVER['PHP_AUTH_PW']; if(!empty($row["Username"]) AND !empty($row["Password"])) { if($_SERVER['PHP_AUTH_PW'] == $row["Password"]) { $_SESSION['user'] = $row["Username"]; echo "Login Succefull, " . $_SESSION['user'] . "!"; } else { die("<br>Wrong password!"); //THIS GETS ON THE SCREEN. };} else { echo "You entered wrong username and/or password. Please refresh this page to retry. It may be possible that your account doesn't exist. In this case, cancel the login box and sign up."; } } } // query failed else { $error = $db->errorInfo(); trigger_error('Unable to process login query. DB Error: ' . $error[2]); } } ?> I cutted unnecessary lines that are found above, in other replyes. The output: Database found. Searching for your user account. Please be patient. dan***srl dan***srl Wrong password! For testing,, the password is dan***srl. PLEASE TELL ME WHY IS IT WRONG PASSWORD IF THEY ARE THE SAME? I censored the passwords, in the entered field and database there are not any stars/asterisks.
  8. Notice: Unable to process login query. DB Error: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. (SQLExecute[-3010] at ext\pdo_odbc\odbc_stmt.c:254) in C:\xampp\htdocs\login.php on line 87 I suppose this is from database and not PHP related, but someone has the solution?
  9. Fatal error: Call to undefined method PDO::erroInfo() in C:\xampp\htdocs\login.php on line 86 There: $error = $db->erroInfo();
  10. Hello! I wrote the folowing script. It basically sends a HTML 401 Unauthorized error that displays a login box. After that it collects the info an does the login stuff that a form does. Now, here comes the problems: In both Access and MySQL connections method (basically only the method to connect is different because both use SQL, just one is a file and other is a server) I get this error: Fatal error: Call to a member function fetch() on boolean in C:\xampp\htdocs\login.php on line 66 Here is the file: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); 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>"; unset($_SERVER['PHP_AUTH_USER']); unset($_SERVER['PHP_AUTH_PW']); exit; } else { #Connecting to database $dbFile = $_SERVER["DOCUMENT_ROOT"] . "/LOGINDATABASE.mdb"; if (!file_exists($dbFile)) { die("Database " . $dbFile . " not found! Please copy this error and report it through the contact page."); } else { echo "Database found. Searching for your user account. Please be patient."; } $db = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$dbFile; Uid=; Pwd=;"); #Connected to database #Starting login script $user = $_SERVER['PHP_AUTH_USER']; $pass = $_SERVER['PHP_AUTH_PW']; #Clearing login box if user and pass are set so that a refresh would show the box again #NOT WORKING. HELP! #if (isset($user)) { # if (isset($pass)) { # unset($_SERVER['PHP_AUTH_USER']); # unset($_SERVER['PHP_AUTH_PW']); # } else { # die("Password not set. Copy this and sent it to site administrator through contact page."); # } #} else { # die("Username not set. Copy this and sent it to site administrator through contact page."); #} # #Starting database check for login details $sql = "SELECT *"; $sql .= " FROM Login"; $sql .= " WHERE userName = '" . $user . "'"; $sql .= " AND pass ='" . $pass . "'"; $result = $db->query($sql); while ($row = $result->fetch()) { if(!empty($row["Username"]) AND !empty($row["Password"])) { $_SESSION['user'] = $row["user"]; echo "Login Succefull!"; } else { echo "You entered wrong username and/or password. Please refresh this page to retry. It may be possible that your account doesn't exist. In this case, cancel the login box and sign up."; } } } ?> Also, if you can help me with the line 44-56 part, because it isn't working. (I commented it just to be sure it isn't the problem. Again, thank you for help!
  11. Yes, that one was put there by me, not a mistake! I'm coming back with another post because the problem showed by the earlier one is solved. So, here am I. From earlier post, I modified my code and finally (or not), I have reached this one: <?php error_reporting(E_ALL); ini_set('display_errors', '1'); 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 { $db=new mysqli('localhost', 'DanCojocaru', 'danutzsrl', 'dan cojocaru'); /* //$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 { $sql = "<<<sql SELECT * FROM `UserName` WHERE userName = '" . $_SERVER['PHP_AUTH_USER'] . "' AND pass ='" . $_SERVER['PHP_AUTH_PW'] . "' SQL;"; $row = $mysqli->query($sql)->fetch_array(); if(!empty($row['userName']) AND !empty($row['pass'])) { $_SESSION['userName'] = $row['pass']; echo "SUCCESSFULLY LOGIN TO USER PROFILE PAGE..."; } else { echo "SORRY... YOU ENTERED WRONG ID AND PASSWORD... PLEASE RETRY..."; } } } //if(isset($_POST['submit'])) //{ SignIn(); //} } ?> Basically making a HTML 401 error and after error trying to match the info provided with the MySQL database named dan cojocaru. Here are the problems. After loading this page, guess, error! Notice: Undefined variable: mysqli in C:\xampp\htdocs\test3.php on line 41 Fatal error: Call to a member function query() on null in C:\xampp\htdocs\test3.php on line 41 Please help!
  12. Just a tip, your answer would be better if you had told me how to do that, not just how to do it...
  13. 1. That was a joke, ok? If I didn't knew what kind of thing programming is, I wouldn't choose IT High School as my first high school option. 2. Now, it shows me this: Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:\xampp\htdocs\test3.php on line 29
  14. Ok, I think I will leave PHP programming. Now it just shows a blank page. Could someone copy and test with the code, maybe it's something wrong with my PC. This is the code at the momment of the post. <?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 = '" . $_SERVER['PHP_AUTH_PW'] . "'") or die(mysql_error()); $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 ENTERED WRONG ID AND PASSWORD... PLEASE RETRY..."; } } } //if(isset($_POST['submit'])) //{ SignIn(); //} } ?>
  15. Thank you! I can't belive I missed that! But now, I got another error: Unknown column 'dancojocaru' in 'where clause' (dancojocaru is the name I entered in the username field at the login box) How can I get past this one?
  16. 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.
×
×
  • 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.