Unable to add to Database via web form

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Fegero
Forum Newbie
Posts: 7
Joined: Sat Jul 20, 2002 6:10 pm

Unable to add to Database via web form

Post 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
Paddy
Forum Contributor
Posts: 244
Joined: Wed Jun 11, 2003 8:16 pm
Location: Hobart, Tas, Aussie
Contact:

Post 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
Fegero
Forum Newbie
Posts: 7
Joined: Sat Jul 20, 2002 6:10 pm

Seems to be going good- THANKS

Post 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
Post Reply