Jump to content

mikebyrne

Members
  • Posts

    780
  • Joined

  • Last visited

Posts posted by mikebyrne

  1. Ok I'm starting to get the hang of it. Im getting an Array when I echo error so i know its finding the errorlist.

     

    I'm trying to fix an if statment that only lets it insert if there is no array but the way I've tried doesn't reconise the "="

     

    Could anyone point me in the right direction??

  2. I've been playing around with it. Am I on the right track with this?

     

    <?php
    
    $errorList = array();
    $name = mysql_real_escape_string ($_POST['name']);
    $age = mysql_real_escape_string ($_POST['age']);
    $location = mysql_real_escape_string ($_POST['location']);
    $mydropdown1 = mysql_real_escape_string ($_POST['mydropdown1']);
    $reason = mysql_real_escape_string ($_POST['reason']);
    $mydropdown2 = mysql_real_escape_string ($_POST['mydropdown2']);
    
    
    
    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'];
    
    if ($mydropdown2 = "YES") {
         if ($which = "") {
              echo "Error, you must enter which chatsite you work for";
    	  $errorList[] = 'Please enter the chatsite you worked for';
         }
    }
    else {
    echo "They picked NO";
    }
    
    
    // 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());
    
    
    ?>
    
    

  3. <?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'];
    
    if ($mydropdown2 = "YES") {
         if ($which = "") {
              echo "Error, you must enter which chatsite you work for";
         }
    }
    else {
    echo "They picked NO";
    }
    
    
    // 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());
    
    
    ?>
    

     

    Have I placed the if statement in the wrong place?

     

    I leave it to Yes, leave the last field blank but it still passes info to database

  4. Could someone give me an example on how i could write the validation?

     

     

    The main one i have a problem with is the If statemnt ie If the user selects Yes on the the Do you work for a "chatsite option" they HAVE to fill out the last field

  5. The validation I would require (at a glance) should be:

     

    1) Only numeric can be entered on the age field

     

    2) A positon from (mydropdown1) HAS to be selected and cant be left "Please Select Option"

     

    3) 1 option from (mydropdown2) HAS to be selected and cant be "Please select Option"

     

    4) I'll need a simple If statement saying IF the user has selected they work for a chatsite they HAVE to fill out the "If so, which one" filed

     

    Again, If you can help me out it would be great

     

    Here's my code

    
    <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="Option1">Please select Option</option>
          <option value="NO">NO</option>
          <option value="YES">YES</option>
             </select>
             </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" name="submit" value="Apply"></td>
        </tr>
      </table>
    </form>
    </body>
    

     

    php page

     

    
    <?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'];
    
    echo $name;
    echo $age;
    echo $location;
    echo $mydropdown1;
    echo $reason;
    echo $mydropdown2;
    echo $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());
    
    
    ?>
    

     

    Any help in coding the validation would be great!!!!!

  6. The validation I would require (at a glance) should be:

     

    1) Only numeric can be entered on the age field

     

    2) A positon from (mydropdown1) HAS to be selected and cant be left "Please Select Option"

     

    3) 1 option from (mydropdown2) HAS to be selected and cant be "Please select Option"

     

    4) I'll need a simple If statement saying IF the user has selected they work for a chatsite they HAVE to fill out the "If so, which one" filed

     

    Again, If you can help me out it would be great

  7. No still the same

     

    My code is:

     

    <body>
    
    <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>
    	<tr>
          <td><input type="submit" value="Apply"></td>
        </tr>
      </table>
    </form>
    </body>
    

     

     

    <?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'] ;
    
    echo $name;
    echo $Age;
    echo $Location;
    echo $mydropdown1;
    echo $Reason;
    echo $mydropdown2;
    echo $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());
    
    ?>
    

     

    And the SQL is:

     

    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=20 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci

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

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

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

     

     

  11. 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());
    
    ?>
    

     

     

  12. 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());
    
    ?>
    

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

×
×
  • 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.