Page 1 of 1

Unable to add to Database via web form

Posted: Tue Dec 16, 2003 4:27 pm
by Fegero
Iam having problems doing inputs over the web. I am unsure why. Here is some code

index.php

<html>
<body>
<form action="comehere.php" method="post">
<input type="text" name="myname">
<input type=submit value="submit">
</form>
</body>
</html>

I have tried with and without "" around text and around filenames

comehere.php
let me make this even easier, I'll skip the database input and write this:
<html>
<body>
<?
if (!$myname){
echo "you have a problem";
exit;
}
#database code here
?>
</body>
</html>

ONLY the you have a problem will show up. There for my data is not getting sent. If I comment out that line and let everything go to the db then I get empty rows in the db.

Am I screwing up on permissions or something?

#2) When I look under the mysql database user table, I log in as myname. I do a select host,user from user; I receive a list like such

localhost root
localhost myname
% myname

What is %

thanks,

Fegero

Posted: Tue Dec 16, 2003 4:48 pm
by Paddy
More than likely you have global variables turned off. Which is a good thing. Use

$myname = (isset($_POST['myname'])?$_POST['myname']:"");

prior to doing your if statement in comehere.php

Seems to be going good- THANKS

Posted: Tue Dec 16, 2003 5:00 pm
by Fegero
So far so good. I have to go back and test some more pieces to my code, but I think your $_POST line works. I will have to look that up to understand a little more about it.

Thanks again for your help. It's appreciated.

Fegero