/    Sign up×
Community /Pin to ProfileBookmark

A script that just don’t response…

Hi!,
I wrote a simple script that’s receives an POST array from an HTML form,
Runs a line of simple checks, and inserts the a fresh user profile to the data base, in ideal…
But it just won’t work, it won’t even returns an error(it should tho)…
can some one just take a look at the phrase, I’m sure that my mistake quite nublsih, and wouldn’t take much of an effort to trace it…
Thanks in advance…

[code=php]<?php
If($_SERVER[‘HTTP_REFERER’]=$_SERVER[‘PHP_SELF’] or isset($_POST[‘check’]))
{
if(isset($_POST[‘name’]) and isset($_POST[‘name2’]) and isset($_POST[‘password’]) and isset($_POST
[‘password2’]) and isset($_POST[‘mail’]) and isset($_POST[‘mail2’]))
{
$link=mysql_connect(“127.0.0.1”, “root”, “”) or die(mysql_error());
mysql_select_db(“users”, $link) or die(mysql_error());
if(strcmp($password, $password2)!=0)
{
$submit=0;
$message=”The passwords you entered doesn’t match.”;
}
if(strcmp($mail1, $mail)!=0)
{
$submit=0;
$message=$message.”<br>The email addresses you have entered doesn’t match.”;
}
if(submit!=0)
{
$results=mysql_query(“INSERT INTO users(name, password, date, msn, icq, email)
VALUES(“.$_POST[‘name’].”, “.md5($_POST[‘password’]).”, “. time().”,”.$_POST[‘msn
‘].”, “.$_POST[‘icq’].”,
“.$_POST[’email’].”)”, $link) or die(mysql_error());
print(“jarjar”);
}
print($message);
if(!isset($submit))
print(“Success!”);
}
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=” />
<title>Untitled Document</title>
</head>

<body>
<form method=”post” action=”<?php print($_SERVER[‘PHP_SELF’]);?>”>
<table width=”70%” border=”0″ cellspacing=”1″ cellpadding=”0″ align=”right” dir=”rtl”>
<tr>
<td width=”20%”>User name*</td>
<td width=”30%”><input type=”text” dir=”rtl” align=”right” name=”name” maxlength=”12″ /></td>
<td width=”20%”>Retype E-mail* </td>
<td><input type=”text” dir=”rtl” align=”right” name=”email2″ maxlength=”30″ /></td>

</tr>
<tr>
<td>password*</td>
<td><input type=”text” dir=”rtl” align=”right” name=”password” maxlength=”20″ /></td>
<td width=”20%”>Msn messengr ID</td>
<td><input type=”text” dir=”rtl” align=”right” name=”msn” maxlength=”20″ /></td>

</tr>
<tr>
<td>retype password*</td>
<td><input type=”text” dir=”rtl” align=”right” name=”password2″ maxlength=”30″ /></td>
<td>ICQ number </td>
<td><input type=”text” dir=”rtl” align=”right” name=”icq” maxlength=”12″ /></td>

</tr>
<tr>
<td width=”20%”>Contact E-mail*</td>
<td><input type=”text” dir=”rtl” align=”right” name=”email” maxlength=”30″ /> </td>

</tr>
<tr><td><input type=”submit” dir=”rtl” align=”right” value=”send” /></td></tr>
</table>
<input type=”hidden” name=”check” value=”1″ />
</form>
</body>
</html>[/code]

to post a comment
PHP

10 Comments(s)

Copy linkTweet thisAlerts:
@chazzyJan 06.2006 — this line is wrong:
[code=php]
If($_SERVER['HTTP_REFERER']=$_SERVER['PHP_SELF'] or isset($_POST['check']))
[/code]


lower case "if" and need a double equal sign for checking.
Copy linkTweet thisAlerts:
@NogDogJan 06.2006 — [code=php]
if(isset($_POST['name']) and isset($_POST['name2']) and isset($_POST['password']) and isset($_POST
['password2']) and isset($_POST['mail']) and isset($_POST['mail2']))
[/code]

Check the field names you're testing for in this line versus the input names used in your form. You'll find they do not all match exactly (e.g. "mail2" should be "email2") or do not even exist (e.g. "name2"). Thus you never get past this if condition.
Copy linkTweet thisAlerts:
@NogDogJan 06.2006 — this line is wrong:
[code=php]
If($_SERVER['HTTP_REFERER']=$_SERVER['PHP_SELF'] or isset($_POST['check']))
[/code]


lower case "if" and need a double equal sign for checking.[/QUOTE]

Not sure that the case of "if" matters, but you definitely want the comparison "==" and not the assignment "=". (Good eye, Chazzy.)
Copy linkTweet thisAlerts:
@chazzyJan 06.2006 — just checked, if's a keyword, IF's not a keyword, so I'd assume that If's not a keyword either.
Copy linkTweet thisAlerts:
@NogDogJan 06.2006 — just checked, if's a keyword, IF's not a keyword, so I'd assume that If's not a keyword either.[/QUOTE]
This worked just fine for me:
[code=php]
<?php
IF(false)
{
ECHO "This is the IF clause.";
}
ElSeIf(TRUE)
{
PrInT("This is the ElSeIf clause.");
}
ElSe
{
EcHo "This is the ElSe clause.";
}
?>
[/code]
Copy linkTweet thisAlerts:
@HellgYauthorJan 06.2006 — Thanks guys!, i guess that those was indeed the problems that prevented the script from running, i thought that it's the the external conditions... I haven't verified this speculation tho...

Thanks Chazzy and NogDog!, your help meant a great deal for a lazy N00B.
Copy linkTweet thisAlerts:
@HellgYauthorJan 06.2006 — Here is my code after the modifications you recommended was applied, still the same old problem:.
[CODE]<?php
If($_SERVER['HTTP_REFERER']==$_SERVER['PHP_SELF'] or isset($_POST['check']))
{

if(!isset($_POST['name']) or !isset($_POST['name2']) or !isset($_POST['password']) or !isset($_POST
['password2']) or !isset($_POST['email']) or !isset($_POST['email2']))
$message="You must fill all the fields marked with *";
else
{

$link=mysql_connect("127.0.0.1", "root", "") or die(mysql_error());
mysql_select_db("nba", $link) or die(mysql_error());
if(strcmp($_POST['password'], $_POST['password2'])!=0)
{
$submit=0;
$message=$message."The passwords you entered doesn't match.";
}
if(strcmp($_POST['email'], $_POST['email2'])!=0)
{
$submit=0;
$message=$message."<br>The email addresses you have entered doesn't match.";
}
if(submit!=0)
{
$results=mysql_query("INSERT INTO users(name, password, date, msn, icq, email)
VALUES(".$_POST['name'].", ".md5($_POST['password']).", ". time().",".$_POST['msn
'].", ".$_POST['icq'].",
".$_POST['email'].")", $link) or die(mysql_error());
print("jarjar");
}
if(!isset($submit))
print("Success!");
else
print($message);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=" />
<title>Untitled Document</title>
</head>

<body>
<form method="post" action="<?php print($_SERVER['PHP_SELF']);?>">
<table width="70%" border="0" cellspacing="1" cellpadding="0" align="right" dir="rtl">
<tr>
<td width="20%">User name*</td>
<td width="30%"><input type="text" dir="rtl" align="right" name="name" maxlength="12" /></td>
<td width="20%">Retype E-mail* </td>
<td><input type="text" dir="rtl" align="right" name="email2" maxlength="30" /></td>

</tr>
<tr>
<td>password*</td>
<td><input type="text" dir="rtl" align="right" name="password" maxlength="20" /></td>
<td width="20%">Msn messengr ID</td>
<td><input type="text" dir="rtl" align="right" name="msn" maxlength="20" /></td>

</tr>
<tr>
<td>retype password*</td>
<td><input type="text" dir="rtl" align="right" name="password2" maxlength="30" /></td>
<td>ICQ number </td>
<td><input type="text" dir="rtl" align="right" name="icq" maxlength="12" /></td>

</tr>
<tr>
<td width="20%">Contact E-mail*</td>
<td><input type="text" dir="rtl" align="right" name="email" maxlength="30" /> </td>

</tr>
<tr><td><input type="submit" dir="rtl" align="right" value="send" /></td></tr>
</table>
<input type="hidden" name="check" value="1" />
</form>
</body>
</html>[/CODE]
Copy linkTweet thisAlerts:
@HellgYauthorJan 07.2006 — Some one?, help?, please?.
Copy linkTweet thisAlerts:
@rincewind456Jan 07.2006 — These are the varaibles that your form sets[code=php]

$_POST["name"]
$_POST["email2"]
$_POST["password"]
$_POST["msn"]
$_POST["password2"]
$_POST["icq"]
$_POST["email"]
$_POST["check"]
[/code]

These are the variables that you are checking[code=php]
$_POST['name']
$_POST['name2'] //###
$_POST['password']
$_POST['password2'
$_POST['email']
$_POST['email2']
[/code]


Notice the odd one out?
Copy linkTweet thisAlerts:
@HellgYauthorJan 07.2006 — I'm sorry by you're mistaking... I only check the identically of the passwords and the E-mail addresses, Thanks for trying to help!.

EDIT: I'm sorry!, you are right, i am checking the existence 'name2' and never getting past this condition...

I thought that you are talking about the strings i verify being identical...
×

Success!

Help @HellgY spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...