Reputation: 19
I have stared at this code for an hour and can't figure this out to save my life. maybe I need more coffee
I'm creating a switch register page but every time I submit the form it refreshes the default page heres the code cut down extensively.
include("../tools/config.php");
session_start();
switch($_GET['action']){
case "joinb":
addmember($member);
break;
default:
register($user);
break;
}
function register($user){
echo "
<form method='post'>
data blah blah
<input type='hidden' name='action' value='joinb'>
<input type='submit' class='button' name='submit' value='Create Account'>
</form>
";
}
function addmember($member){
insert mysql function
}
Upvotes: 0
Views: 40
Reputation: 18569
Your form is submitted with POST
method, so you should check $_POST['action']
instead of $_GET['action']
Upvotes: 0
Reputation: 164892
Well, you're POSTing the form so $_GET['action']
will not be populated. I would drop the switch
and use...
if (isset($_POST['action']) && $_POST['action'] === 'joinb') {
addmember($member);
} else {
register($user);
}
Upvotes: 2