By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,347 Members | 1,390 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,347 IT Pros & Developers. It's quick & easy.

php mysql form isset wont work

P: 35
I have a php page with a form....the form has a hidden variable called subjoin. with a value of 1

in the page the data is posted to i have the following code
[php]
<?
include("includes/database.php");
?>
<?php
if(isset($_POST['subjoin'])){
// ADD A NEW CUSTOMER
mysql_query("INSERT INTO details
(id, customername, companyname, building, street, town, county, postcode, telephone1, telephone2, telephone3, email) VALUES('', '$_POST[customername]', '$_POST[companyname]', '$_POST[building]', '$_POST[street]', '$_POST[town]', '$_POST[county]', '$_POST[postcode]', '$_POST[telephone1]', '$_POST[telephone2]', '$_POST[telephone3]', '$_POST[email]') ")
or die(mysql_error());
echo "New Customer Added";}
?>
[/php]
i am going to have multiple forms going to this page so i need a way of defining which form has been submitted....but what i have above just wont work....have i missed something simple?

i know this code is probably old or messy but i just want to know what im doing wrong with it.

thx

And messy it is. Please enclose any code within the appropriate code tags. See the Posting Guidelines! - moderator
Feb 27 '08 #1
Share this Question
Share on Google+
3 Replies


Markus
Expert 5K+
P: 6,050
Can you not have different names for the submit buttons?
[php]
if(isset($_POST['form1']))
{
// code for form one
}
elseif(isset($_POST['form2'))
{
// code forform 2
}
//so on and so forth..
[/php]
Feb 27 '08 #2

P: 35
Can you not have different names for the submit buttons?
[php]
if(isset($_POST['form1']))
{
// code for form one
}
elseif(isset($_POST['form2'))
{
// code forform 2
}
//so on and so forth..
[/php]
yeah that works....hmm.....so why cant i use an input variable.....i just copied that method from another php script and it worked for them...oh well...thanks for that..solves the prob ;0)
Feb 27 '08 #3

Markus
Expert 5K+
P: 6,050
yeah that works....hmm.....so why cant i use an input variable.....i just copied that method from another php script and it worked for them...oh well...thanks for that..solves the prob ;0)
No problamo!

Not sure why the other way didn't work.. but this is the more commanly used approach/.
Feb 27 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.