Form Action - PHP function?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ununium
Forum Newbie
Posts: 5
Joined: Sun Oct 26, 2008 11:28 pm

Form Action - PHP function?

Post by ununium »

I am writing a form that will create a user in my application. I have a page called AddUser,php which contains the form. I want the php code that I use to check the input and store in the database to be on this same page, but I have no idea how to do it. I set the form action to "AddUser.php" but it ended up creating a blank entry in my database in addition to the submitted info. I tried adding an onclick on the submit button that would call a php function on that page but that didn't work either. A friend told me to use a hidden input field to accomplish this, but is there an easier way?
sirish
Forum Newbie
Posts: 8
Joined: Tue Sep 09, 2008 11:45 pm

Re: Form Action - PHP function?

Post by sirish »

Did u keep the inserting part in an if condition? I guess not. Maybe thats the reason why a blank entry is inserted in your database.


if($_SERVER['REQUEST_METHOD']=="POST"){
//insert code
}
OR
if(isset($_POST['Submit'])){
//insert code
}
OR
if($_POST){
//insert code
}
ununium
Forum Newbie
Posts: 5
Joined: Sun Oct 26, 2008 11:28 pm

Re: Form Action - PHP function?

Post by ununium »

Yes, thank you. It wasn't in an if statement :)
Post Reply