Jump to content

[SOLVED] php form...its not working


sushank

Recommended Posts

help me.....its not working......

i have seen this code in wrox professional php programming....and try to run it...... <HTML>

<FORM>

Please type your name here:<BR>

<INPUT TYPE=TEXT NAME=username><BR><BR>

<INPUT TYPE=SUBMIT VALUE="Submit data">

</FORM>

<BR><BR>

You typed:

<?php

echo ($username);

?>

</HTML>

 

when we enter the name and press the submit button its should print wat ever u have entered...but its not working...can any please tell me wats the problem....and i am using wamp 1.7.2.........waiting for ur replies........

Link to comment
https://forums.phpfreaks.com/topic/68702-solved-php-formits-not-working/
Share on other sites

OK well global register is off (thats good), so your need to tell the form and the php which method to use

e.g.

<HTML>
<FORM method="post">
Please type your name here:<BR>
<INPUT TYPE="TEXT" NAME="username"><BR><BR>
<INPUT TYPE="SUBMIT" VALUE="Submit data">
</FORM>
<BR><BR>
You typed:
<?php
echo $_POST['username'];
?>
</HTML>

See here

register_globals

 

I'll stress that running PHP with register globals turned on, though convenient, opens unnecessary security risks.

 

Example

 

<HTML>
<FORM>
Please type your name here:<BR>
<INPUT TYPE="TEXT" NAME="username"><BR><BR>
<INPUT TYPE="SUBMIT" VALUE="Submit data">
</FORM>
<BR><BR>
You typed:
<?php
//$admin = false; //without this line theirs a security hole!!!!!
echo $username;
if($username == "ADMIN")
{
$admin = true;
}
//....................other code
if($admin)
{
echo "<br />Welcome Admin";
}
?>
</HTML>

 

now if i used the name as ADMIN i am the administartor anything else an i am not.. BUT

 

if i load the page like this TEST.php?admin=1 then $admin will be 1 (aka true) thus anyuser could be the admin, this can be corrected by setting $admin to false at the start of the script but still it could be missed!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.