mikebyrne Posted December 7, 2007 Share Posted December 7, 2007 Hi guys, Im doing a page for a friend but there is dropdown menus so im not sure how to set them as varibles. Here my work so far: <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <td><form name="form1" method="post" action="signupsnake.php"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Name:</td> <td><input type="text" name="name" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Age:</td> <td><input type="number" name="Age" value="" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Location:</td> <td><input type="text" name="Location" value="" size="32"></td> </tr> <select name="mydropdown1" size="1"> <option value="Option">Please Select Option</option> <option value="Help Operator">Help Operator</option> <option value="Moderator">Moderator</option> <option value="Senior Moderator">Senior Moderator</option> <option value="IRCop">IRCop</option> <option value="Administrator">Administrator</option> </select> /tr> <tr valign="baseline"> <td nowrap align="right">Reason for Application:</td> <td><input type="text" name="Reason" value="" size="32"></td> </tr> <select name="mydropdown2" size="1"> <option value="Option">Do you work for any chatsite?</option> <option value="YES">YES</option> <option value="NO">NO</option> <tr valign="baseline"> <td nowrap align="right">If so, Which one?:</td> <td><input type="text" name="which" value="" size="32"></td> </tr> <td><input type="submit" value="Apply"></td> </tr> </table> </form> <p> </p> </body> </html> If you can tell me how to put the listbox in line that would be great!!! <?php include('config1.php'); // table name $tbl_name=applications; // values sent from form $name=$_POST['Username']; $Age=$_POST['Age']; $Location=$_POST['Location']; $mydropdown1=$_POST['Position']; $Reason=$_POST['Reason']; $mydropdown2=$_POST['Workonsite']; $which=$_POST['Whatsite']; // Insert data into database $sql="INSERT INTO $tbl_name(Username,Age,Location,Position,Reason,Workonsite,Whatsite)VALUES('$Username', '$Age', '$Location', '$Position', '$Reason','$Workonsite', '$Whatsite')"; $result=mysql_query($sql)or die(mysql_error()); ?> Plus the SQL of database CREATE TABLE `applications` ( `Userid` int(11) NOT NULL auto_increment, `Username` int(11) default NULL, `Age` int(11) default NULL, `Location` int(11) default NULL, `Position` int(11) default NULL, `Reason` int(11) default NULL, `Workonsite` int(11) default NULL, `Whatsite` int(11) default NULL, PRIMARY KEY (`Userid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 7, 2007 Share Posted December 7, 2007 You get the value of the drop-down just like any other value, with the name. So all you would do is $mydropdown1=$_POST['mydropdown1']; Quote Link to comment Share on other sites More sharing options...
revraz Posted December 7, 2007 Share Posted December 7, 2007 $mydropdown1=$_POST['mydropdown1']; $mydropdown2=$_POST['mydropdown2']; Also becareful on your variables. Some you have the first letter in caps, some you don't. Try to make them consistant or you'll wonder why your variable is empty since $Variable is not the same as $variable. Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted December 7, 2007 Author Share Posted December 7, 2007 Sorry its messy its just something I banged together quickly for testing Any idea how I can allign the dropdown menus in the right place?? Quote Link to comment Share on other sites More sharing options...
revraz Posted December 7, 2007 Share Posted December 7, 2007 Not sure what you mean by the right place. Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted December 7, 2007 Author Share Posted December 7, 2007 LOL sorry. Doing two things at once here I want everything underneath each other at the moment the two drop down list are on the left hand side Username Age Location Position applying for (listbox) Why Do you work for a chatsite (listbox) if so, who? At present the listboxs are in the top left (I know its nothing to do with php!! lol) Quote Link to comment Share on other sites More sharing options...
revraz Posted December 7, 2007 Share Posted December 7, 2007 <body> <td><form name="form1" method="post" action="signupsnake.php"> <table align="center"> <tr valign="baseline"> <td>Name:</td> <td><input type="text" name="name" value="" size="32"></td> </tr> <tr valign="baseline"> <td >Age:</td> <td><input type="number" name="Age" value="" size="32"></td> </tr> <tr valign="baseline"> <td>Location:</td> <td><input type="text" name="Location" value="" size="32"></td> </tr> <tr> <td>Position Applying For</td> <td> <select name="mydropdown1" size="1"> <option value="Option">Please Select Option</option> <option value="Help Operator">Help Operator</option> <option value="Moderator">Moderator</option> <option value="Senior Moderator">Senior Moderator</option> <option value="IRCop">IRCop</option> <option value="Administrator">Administrator</option> </select> </td> </tr> <tr valign="baseline"> <td>Reason for Application:</td> <td><input type="text" name="Reason" value="" size="32"></td> </tr> <tr> <td>Do you work for any chatsite?</td> <td> <select name="mydropdown2" size="1"> <option value="YES">YES</option> <option value="NO">NO</option> </td> </tr> <tr valign="baseline"> <td>If so, Which one?:</td> <td><input type="text" name="which" value="" size="32"></td> </tr> <tr> <td><input type="submit" value="Apply"></td> </tr> </table> </form> </body> Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted December 7, 2007 Author Share Posted December 7, 2007 Cheers!! The only thing being passed to my database is the Age Any idea why?? I also want to notify the user ther application is being processed Quote Link to comment Share on other sites More sharing options...
revraz Posted December 7, 2007 Share Posted December 7, 2007 Because your Database fields are all set to INT, so since Age is the only valid number, that's all that will get entered. Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted December 7, 2007 Author Share Posted December 7, 2007 Sorry, didnt notice that Username, position, workonsite & Whatsite still aren't being posted to the DB Quote Link to comment Share on other sites More sharing options...
revraz Posted December 7, 2007 Share Posted December 7, 2007 Check your variables, they dont match. You have this $which=$_POST['Whatsite']; but in your form you have <td><input type="text" name="which" value="" size="32"></td> So you either need to change the $_post['which'] or your input name to "Whatsite" Same with your other variables. Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted December 7, 2007 Author Share Posted December 7, 2007 <?php include('config1.php'); // table name $tbl_name=applications; // values sent from form $name=$_POST['Username']; $Age=$_POST['Age']; $Location=$_POST['Location']; $mydropdown1=$_POST['Position']; $Reason=$_POST['Reason']; $mydropdown2=$_POST['Workonsite']; $which=$_post['which'] ; // Insert data into database $sql="INSERT INTO $tbl_name(Username,Age,Location,Position,Reason,Workonsite,Whatsite)VALUES('$Username', '$Age', '$Location', '$Position', '$Reason','$Workonsite', '$Which')"; $result=mysql_query($sql)or die(mysql_error()); ?> There still not posting to the db Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted December 7, 2007 Author Share Posted December 7, 2007 I cant get the "which" inpur to post to the table. The rest are working fine <?php include('config1.php'); // table name $tbl_name=applications; // values sent from form $name=$_POST['Username']; $Age=$_POST['Age']; $Location=$_POST['Location']; $mydropdown1=$_POST['mydropdown1']; $Reason=$_POST['Reason']; $mydropdown2=$_POST['mydropdown2']; $which=$_post['which'] ; // Insert data into database $sql="INSERT INTO $tbl_name(Username,Age,Location,Position,Reason,Workonsite,Whatsite)VALUES('$Username', '$Age', '$Location', '$mydropdown1', '$Reason','$mydropdown2', '$which')"; $result=mysql_query($sql)or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted December 7, 2007 Author Share Posted December 7, 2007 Sorry username wasnt working but I fixed that. Still cant get the last one to work <?php include('config1.php'); // table name $tbl_name=applications; // values sent from form $name=$_POST['name']; $Age=$_POST['Age']; $Location=$_POST['Location']; $mydropdown1=$_POST['mydropdown1']; $Reason=$_POST['Reason']; $mydropdown2=$_POST['mydropdown2']; $which=$_post['which'] ; // Insert data into database $sql="INSERT INTO $tbl_name(Username,Age,Location,Position,Reason,Workonsite,Whatsite)VALUES('$name', '$Age', '$Location', '$mydropdown1', '$Reason','$mydropdown2', '$which')"; $result=mysql_query($sql)or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted December 7, 2007 Share Posted December 7, 2007 Capitalize POST Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted December 7, 2007 Author Share Posted December 7, 2007 Good spot, but it still didnt fix it Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted December 8, 2007 Author Share Posted December 8, 2007 CAnt figure out why the last one wont pass to the dadtbase. I've tried everything!!!!! Quote Link to comment Share on other sites More sharing options...
revraz Posted December 8, 2007 Share Posted December 8, 2007 Post the updated SQL Table layout Also, before you do the SQL Query, Echo each variable to the screen and see what they look like. Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted December 8, 2007 Author Share Posted December 8, 2007 CREATE TABLE `applications` ( `Userid` int(11) NOT NULL auto_increment, `Username` int(11) default NULL, `Age` int(11) default NULL, `Location` int(11) default NULL, `Position` int(11) default NULL, `Reason` int(11) default NULL, `Workonsite` int(11) default NULL, `Whatsite` int(11) default NULL, PRIMARY KEY (`Userid`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci The outputs from the echos are: Mike28IrelandHelp OperatorfunYES so there all posting apart from the last one Quote Link to comment Share on other sites More sharing options...
revraz Posted December 8, 2007 Share Posted December 8, 2007 Your DB still shows INT for those values. I thought you changed them. Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted December 8, 2007 Author Share Posted December 8, 2007 CREATE TABLE `applications` ( `Userid` int(11) NOT NULL auto_increment, `Username` varchar(20) collate latin1_general_ci default NULL, `Age` int(11) default NULL, `Location` varchar(25) collate latin1_general_ci default NULL, `Position` varchar(40) collate latin1_general_ci default NULL, `Reason` varchar(47) collate latin1_general_ci default NULL, `Workonsite` varchar(3) collate latin1_general_ci default NULL, `Whatsite` varchar(12) collate latin1_general_ci default NULL, PRIMARY KEY (`Userid`) ) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci Quote Link to comment Share on other sites More sharing options...
revraz Posted December 8, 2007 Share Posted December 8, 2007 Ah, we forgot to end the SELECT here <td>If so, Which one?:</td> <td><input type="text" name="which" value="" size="32"></td> </tr> to <td>If so, Which one?:</td> <td><input type="text" name="which" value="" size="32"></td> </tr> </select> Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted December 8, 2007 Author Share Posted December 8, 2007 <body> <td><form name="form1" method="post" action="signupsnake.php"> <table align="center"> <tr valign="baseline"> <td>Name:</td> <td><input type="text" name="name" value="" size="32"></td> </tr> <tr valign="baseline"> <td >Age:</td> <td><input type="number" name="Age" value="" size="32"></td> </tr> <tr valign="baseline"> <td>Location:</td> <td><input type="text" name="Location" value="" size="32"></td> </tr> <tr> <td>Position Applying For</td> <td> <select name="mydropdown1" size="1"> <option value="Option">Please Select Option</option> <option value="Help Operator">Help Operator</option> <option value="Moderator">Moderator</option> <option value="Senior Moderator">Senior Moderator</option> <option value="IRCop">IRCop</option> <option value="Administrator">Administrator</option> </select> </td> </tr> <tr valign="baseline"> <td>Reason for Application:</td> <td><input type="text" name="Reason" value="" size="32"></td> </tr> <tr> <td>Do you work for any chatsite?</td> <td> <select name="mydropdown2" size="1"> <option value="YES">YES</option> <option value="NO">NO</option> </td> </tr> <tr valign="baseline"> <td>If so, Which one?:</td> <td>If so, Which one?:</td> <td><input type="text" name="which" value="" size="32"></td> </tr> </select> <td><input type="submit" value="Apply"></td> </tr> </table> </form> </body> No, it still doesnt post the variable Quote Link to comment Share on other sites More sharing options...
revraz Posted December 8, 2007 Share Posted December 8, 2007 <body> <td><form name="form1" method="post" action="signupsnake.php"> <table align="center"> <tr valign="baseline"> <td>Name:</td> <td><input type="text" name="name" value="" size="32"></td> </tr> <tr valign="baseline"> <td >Age:</td> <td><input type="number" name="Age" value="" size="32"></td> </tr> <tr valign="baseline"> <td>Location:</td> <td><input type="text" name="Location" value="" size="32"></td> </tr> <tr> <td>Position Applying For</td> <td> <select name="mydropdown1" size="1"> <option value="Option">Please Select Option</option> <option value="Help Operator">Help Operator</option> <option value="Moderator">Moderator</option> <option value="Senior Moderator">Senior Moderator</option> <option value="IRCop">IRCop</option> <option value="Administrator">Administrator</option> </select> </td> </tr> <tr valign="baseline"> <td>Reason for Application:</td> <td><input type="text" name="Reason" value="" size="32"></td> </tr> <tr> <td>Do you work for any chatsite?</td> <td> <select name="mydropdown2" size="1"> <option value="YES">YES</option> <option value="NO">NO</option> </select> </td> </tr> <tr valign="baseline"> <td>If so, Which one?:</td> <td><input type="text" name="which" value="" size="32"></td> </tr> <td><input type="submit" value="Apply"></td> </tr> </table> </form> </body> Quote Link to comment Share on other sites More sharing options...
mikebyrne Posted December 8, 2007 Author Share Posted December 8, 2007 No, still the same. I cant figure it out!!!!!! ??? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.