Jump to content

[SOLVED] Signup with dropdown options


mikebyrne

Recommended Posts

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

 

 

Link to comment
Share on other sites

$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.

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

<?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

Link to comment
Share on other sites

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());

?>

Link to comment
Share on other sites

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());

?>

 

 

Link to comment
Share on other sites

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 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

<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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.