-
Posts
780 -
Joined
-
Last visited
Posts posted by mikebyrne
-
-
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??
-
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()); ?>
-
<?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
-
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
-
Could someone give me an example on how i could write the validation?
-
Sorry guys but im a NOOB when it comes to php. Any examples of how id adapt this for my code?
-
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!!!!!
-
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
-
yeah good piont. I wasnt planning on doing the validation because its not for me but I guess I better make an attempt at it!
Wiil i do the "$name=mysql_real_escape_string ($_POST['name']);" on the html doc or the php??
-
What would you recommend?
-
That works perfect now!
CHEERS AGAIN REV
-
I get an access forbidden error
the page goes to http://localhost/%3C?php%20$_SERVER%20['PHP_SELF']?%3E
How can i modify this??
-
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
-
No, still the same. I cant figure it out!!!!!! ???
-
<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
-
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
-
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
-
CAnt figure out why the last one wont pass to the dadtbase. I've tried everything!!!!!
-
Good spot, but it still didnt fix it
-
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()); ?>
-
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()); ?>
-
<?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
-
Sorry, didnt notice that
Username, position, workonsite & Whatsite still aren't being posted to the DB
-
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
Validation Help
in PHP Coding Help
Posted
Yes that fixed the error but my if statement doesnt seem to prevent the info going to the database