Valhalla Legends Forums Archive | Web Development | [PHP Solved] Form

AuthorMessageTime
PaiD
Ok I cant find out what is wrong with this code of mine and I was hoping someone could spot my problem(s).
[php]
echo ("<html>\n");
echo ("<title>Enter Username/Password</title>\n");
echo ("<p align=\"center\">\n");
echo ("<body bgcolor=\"black\">\n");
echo ("<img src=\"bot.jpg\">\n");
echo ("<form name=\"form1\" method=\"post\" action=\"bot.php\">\n");
echo ("<p align=\"center\">\n");
echo ("<font color=\"#FFFFFF\">Username:</font>");
echo ("<input name=\"User\" type=\"text\" id=\"User\">\n");
echo ("<br>\n");
echo ("<font color=\"#FFFFFF\">Password:</font>");
echo ("<input name=\"Pass\" type=\"text\" id=\"Pass\">\n");
echo ("<br>\n");
echo ("<input type=\"submit\" name=\"Submit\" value=\"Submit\">\n");
echo ("</p>\n");
echo ("</form>\n");
echo ("</body>\n");
echo ("</html>\n");
[/php]
That is the form and when they click Submit I wanted it to go to Bot.php and pass the Post Stuff with it. I cant seem to get it to work right. It keeps going to the Header and being redirected
[php]
$User == $_POST["User"];
$Pass == $_POST["Pass"];
if (!$User) {
  header("location: /wb/bot.jpg");
  Exit;
} else {
$IP = $_SERVER['REMOTE_ADDR'];
$Connection = @mysql_connect("localhost","Username","Password") or die(mysql_error());
$DB = @mysql_select_db("Database Name",$Connection);
$SQL = "INSERT INTO `Users` (`Username`,`Password` , `Ip Address`, `Status`)" .
"VALUES ('$User', '$Pass', '$IP','0')";
@mysql_query($SQL,$Connection) or die(mysql_error());
mysql_close($Connection);
}
break;
[/php]

Edit: Nevermind. Fixed. Not sure how but I was just messing with it and now it works :o
November 1, 2005, 10:37 AM
AC_Drkan
Just as a side note, you don't have to separate every html code into a seperate echo statement, it can be included in 1 without the \n.
December 30, 2005, 8:54 PM
rabbit
You'll want to change[code]if (!$User) {[/code] to [code]if(!isset($_POST)) {[/code]
December 31, 2005, 3:32 PM
FrOzeN
While were posting in a dead and solved topic I might add that you can close the php brackets then use html code and re-open them even during a statement.

Eg,
[code]<?php
$var1 = "hello";
$var2 = "world";

if (($var1 . " " . $var2) == ("hello world")) {
?>
<html>
<head>
  <title>Page Title</title>
</head>
<body>
Hello World!
</body>
</html>
<?
} else {
    echo "Didn't work!";
}
?>[/code]

I find it comes in handy when using alot of html within php. :)
January 3, 2006, 4:10 AM
Quarantine
I'd rather not have my HTML code mixed with my PHP. I like to keep them both seperate for easy maintenence in the future.
January 3, 2006, 5:08 AM

Search