PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
dannyd
Forum Commoner
Posts: 56 Joined: Wed Jan 23, 2008 11:31 am
Post
by dannyd » Wed Feb 27, 2008 1:21 pm
Code: Select all
<?PHP
if (isset($_POST['submit']) && isset($_POST['username']=="admin")) && isset($_POST['password']=="admin")) {
echo 'success';
}
?>
<html><body>
<table width="980" height="500"><tr valign="middle"><td align="center">
<form method="post" action="http://zenit.senecac.on.ca/~php701_081sa20/assn1/login.php"><b>User Name:</b>
<input type="text" name="username" size="20">
<b>Password:</b> <input type="text" name="password" size="20"></form>
<input type="submit" value="submit" name="submit"></td></tr></table>
</body></html>
<?PHP
else {
echo "Login error. Please log in again.";
}
?>
Whats wrong with my code .. I get this error:
Parse error: syntax error, unexpected T_IS_EQUAL, expecting ',' or ')' in /.automount/server1/export/home/php701_081sa20/public_html/login.php on line 3
Mordred
DevNet Resident
Posts: 1579 Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria
Post
by Mordred » Wed Feb 27, 2008 1:43 pm
isset($_POST['username']=="admin")
should be
isset($_POST['username']) && $_POST['username']=="admin"
ditto for the other
dannyd
Forum Commoner
Posts: 56 Joined: Wed Jan 23, 2008 11:31 am
Post
by dannyd » Wed Feb 27, 2008 1:53 pm
Code: Select all
<?PHP
if (isset($_POST['submit']) && isset($_POST['username']) && $_POST['username']=="admin" && isset($_POST['password']) && $_POST['password']=="admin") {
echo 'success';
}
?>
<html><body>
<table width="980" height="500"><tr valign="middle"><td align="center">
<form method="post" action="http://zenit.senecac.on.ca/~php701_081sa20/assn1/login.php"><b>User Name:</b>
<input type="text" name="username" size="20">
<b>Password:</b> <input type="text" name="password" size="20"></form>
<input type="submit" value="submit" name="submit"></td></tr></table>
</body></html>
Not sure if I got it right but it doesnt submit to get the "success".
dannyd
Forum Commoner
Posts: 56 Joined: Wed Jan 23, 2008 11:31 am
Post
by dannyd » Wed Feb 27, 2008 2:21 pm
What im trying to do is ...
to post to itself. If successful redirect to another page .. or else display error.
Jade
Forum Regular
Posts: 908 Joined: Sun Dec 29, 2002 5:40 pm
Location: VA
Post
by Jade » Wed Feb 27, 2008 2:27 pm
Have you tried simplifying it? Try changing the success message to something like this:
Code: Select all
<?php
if ($_POST['submit'])
{
echo "submit is: " . $_POST['submit'] . "<br/>
username is: " . $_POST['username'] . "<br/>
password is: " . $_POST['password'] . " <br/>";
}
?>
At least this way you'd know your getting the values you entered into the input fields.
dannyd
Forum Commoner
Posts: 56 Joined: Wed Jan 23, 2008 11:31 am
Post
by dannyd » Wed Feb 27, 2008 2:37 pm
Code: Select all
<?PHP
if (isset($_POST['submit']))
{
echo "submit is: " . $_POST['submit'] . "<br/>";
echo "username is: " . $_POST['username'] . "<br/>";
echo "password is: " . $_POST['password'] . " <br/>";
}
?>
<html><body>
<table width="980" height="500"><tr valign="middle"><td align="center">
<form method="post" action="http://zenit.senecac.on.ca/~php701_081sa20/assn1/login.php"><b>User Name:</b>
<input type="text" name="username" size="20">
<b>Password:</b> <input type="text" name="password" size="20"></form>
<input type="submit" value="submit" name="submit"></td></tr></table>
</body></html>
I get absolutely nothing when I hit submit. Strange.
Jade
Forum Regular
Posts: 908 Joined: Sun Dec 29, 2002 5:40 pm
Location: VA
Post
by Jade » Wed Feb 27, 2008 2:40 pm
okay, try removing the if ($_POST['submit']) and see if you can see anything.
dannyd
Forum Commoner
Posts: 56 Joined: Wed Jan 23, 2008 11:31 am
Post
by dannyd » Wed Feb 27, 2008 2:40 pm
nevermind im a complete retard .. i put the closing form tag before the submit buttong .. duh
thanks for your help!