[PHP] Form submitting problems
Ok, so for learning purposes I want to make a simple login script, where you enter your name and password and it then checks if they are present in the database.
This is what I have so far: Untitled Document
And this is the script I have.
(It's not finished yet.)
PHP Code:
<?php
if (!isset($_POST['submit'])) {
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
Username: <input type="text" name="user">
Password: <input type="password" name"pass">
<input type="submit" name="submit">
</form>
<?php
}
else {
$host = "localhost";
$user = "pie_designs_net";
$pass = "********";
$db = "pie_designs_net";
$usern = empty($_POST['user']) ? die ("ERROR: Enter an username") : mysql_escape_string($_POST['user']);
$passw = empty($_POST['pass']) ? die ("ERROR: Enter a password") : mysql_escape_string($_POST['pass']);
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect");
mysql_select_db($db) or die ("Unable to select database.");
$query = "SELECT FROM login {user, pass}";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
?>
And as you can see when you enter something in both the boxes, it gives an ERROR saying that you didn't enter a password, while you did.
So my question is, what's wrong with my code?
I've looked all over google, but couldn't find anything that helped.
Re: [PHP] Form submitting problems
Your missing the '=' in your input option.
Code:
Password: <input type="password" name"pass">
Should be
Code:
Password: <input type="password" name="pass">
Your welcome
ShimmyShine
Re: [PHP] Form submitting problems
Ah, thanks a lot man. Kinda stupid I over looked something like that though. :tongue:
Re: [PHP] Form submitting problems
Yeah no problem its the simple things that getcha most of the time lol.
ShimmyShine
Re: [PHP] Form submitting problems
As this thread serves no further purpose, I'll close it to prevent spam.