|
PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 13, 2012 11:09AM | Registered: 1 year ago Posts: 7 |
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 15, 2012 04:03PM | Registered: 1 year ago Posts: 36 |
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 16, 2012 08:36AM | Registered: 1 year ago Posts: 117 |
February 16, 2012 10:38AM | Registered: 1 year ago Posts: 132 |
Language: PHP<?php //when you load page, this set the default of the checkboxes i.e unchecked as stated below $me = 'unchecked'; $you = 'unchecked'; $us = 'unchecked'; //this code deals with the method of how the form is submitted. if (isset($_POST['submit1'])) { /* at this point, the code states that if by POST $me is the same value as tea; the checked box of me will return true */ if(isset($_POST['me'])) { $me = $_POST['me']; if($me == 'tea') { $me = 'checked'; } } /* similarly, the code states that if by POST $you is the same value as coke; the checked box of you will return true */ if(isset($_POST['you'])) { $you = $_POST['you']; if($you == 'coke') { $you = 'checked'; } } /* also, the code states that if by POST $us is the same value as cake; the checked box of us will return true */ if(isset($_POST['us'])) { $us = $_POST['us']; if($us == 'cake') { $us = 'checked'; } } } ?>
try to review this short example and read the comments in the code. Am sure it will help in its own little way. Section completed. Cheers!Language: HTML/*<?php print $me or $you or $us; ?> in the body content retains the the actual action performed! If true (the boxes remain checked) else remain unchecked.*/ <body> <form name="form1" method="POST" action= "t.php"> <input type='checkbox' name='me' value='tea' <?php print $me; ?>> tea<br> <input type='checkbox' name='you' value='coke' <?php print $you; ?>> coke<br> <input type='checkbox' name='us' value='cake' <?php print $us; ?>> cake<br> <br> <input type='submit' value='Choose varieties to remember' name='submit1'></p> </form> </body>
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 19, 2012 12:06PM | Registered: 1 year ago Posts: 37 |
Language: PHP<?PHP if (isset($_POST['Submit1'])) { $user1 = "user1"; $user2 = "user2"; $user3 = "user3"; $user4 = "user4"; $user5 = "user5"; $username = $_POST['username']; if ($username == $user1){ print('Welcome user1'); } else if($username == $user2){ print('Welcome user2'); } else if($username == $user3){ print('Welcome user3'); } else if($username == $user4){ print('Welcome user4'); } else if($username == $user5){ print('Welcome user5'); } else { print('You are not a valid user'); } } else { $username =""; } ?>
Language: PHP<?PHP if (isset($_POST['Submit1'])) { $username = $_POST['username']; switch ($username) { case "user1": print("Welcome user1"); break; case "user2": print("Welcome user2"); break; case "user3": print("Welcome user3"); break; case "user4": print("Welcome user1"); break; case "user5": print("Welcome user1"); break; default: print("You are not a valid user"); } } else { $username =""; } ?>
February 20, 2012 07:27AM | Admin Registered: 7 years ago Posts: 5,213 |
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 20, 2012 02:23PM | Registered: 1 year ago Posts: 36 |

|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 20, 2012 02:36PM | Registered: 1 year ago Posts: 88 |
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 20, 2012 07:30PM | Registered: 1 year ago Posts: 15 |
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 20, 2012 08:37PM | Registered: 1 year ago Posts: 37 |
February 21, 2012 02:25PM | Registered: 1 year ago Posts: 41 |
Language: HTML<input type='checkbox' name='chkboxes' value='1'> 1<br> <input type='checkbox' name='chkboxes' value='2'> 2<br> <input type='checkbox' name='chkboxes' value='3'> 3<br>
February 21, 2012 03:03PM | Admin Registered: 7 years ago Posts: 5,213 |
February 22, 2012 10:33AM | Registered: 1 year ago Posts: 41 |
Language: PHP> <input type='checkbox' name='chkboxes[]' > value='1'> 1<br> > <input type='checkbox' name='chkboxes[]' > value='2'> 2<br> > <input type='checkbox' name='chkboxes[]' > value='3'> 3<br> >

|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 22, 2012 01:37PM | Registered: 1 year ago Posts: 117 |
Language: PHP> <input type='checkbox' name='chkboxes[]' > value='1'> 1<br> > <input type='checkbox' name='chkboxes[]' > value='2'> 2<br> > <input type='checkbox' name='chkboxes[]' > value='3'> 3<br> >

February 25, 2012 04:48PM | Registered: 1 year ago Posts: 41 |
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 25, 2012 07:53PM | Registered: 1 year ago Posts: 41 |
February 25, 2012 08:58PM | Registered: 1 year ago Posts: 132 |
Language: PHP<?php $First_Name = 'firstname'; $Surname = 'surname'; $Full_Name = $First_Name.' '. $Surname; print ('My full name is'.' '.$Full_Name); ?>
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 25, 2012 09:04PM | Registered: 1 year ago Posts: 41 |
February 25, 2012 09:06PM | Registered: 1 year ago Posts: 132 |
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 25, 2012 10:38PM | Registered: 1 year ago Posts: 41 |

|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 27, 2012 11:35AM | Registered: 1 year ago Posts: 88 |
Language: PHP<?php $name = "innocent"; echo $name == "innocent" ? "I love php" : "Couldn\'t be better"; ?>
Language: PHP<?PHP if (isset($_POST['Submit1'])) { $username = $_POST['username']; print ($username == "user1") ? "Welcome user1" : ""; print ($username == "user2") ? "Welcome user2" : ""; print ($username == "user3") ? "Welcome user3" : ""; print ($username == "user4") ? "Welcome user4" : ""; print ($username == "user5") ? "Welcome user5" : ""; } ?>
February 27, 2012 12:15PM | Admin Registered: 7 years ago Posts: 5,213 |
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 27, 2012 09:25PM | Registered: 1 year ago Posts: 18 |
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 28, 2012 08:53AM | Registered: 1 year ago Posts: 10 |
Language: PHP<html> <head> <title>A BASIC FORM IN HTML</title> <?PHP $username=$_POST['username']; if($username=="letmein"){ print("welcome back, friend!"); } else if($username==25){ print("bonus code"); } else{ print("You're not a member of this site"); } ?> </head> <body> <FORM NAME="form1"METHOD="post"ACTION="basicForm.php"> <INPUT TYPE="TEXT" VALUE="username"NAME="username"> <INPUT TYPE="submit" Name="submit1" VALUE="Login"> ` </body> </html>
sorry for adding such silly stuff, i really am just trying to contribute|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes February 29, 2012 10:48PM | Registered: 1 year ago Posts: 41 |
Language: PHP<html> <head> <title>Basic Form Exercise 1</title> <?php if(isset($_POST['Submit2'])) { $user = $_POST["username"]; $pass = $_POST["password"]; //* the list of users $User1_name = 'seether'; $User1_passw = 'jones'; $user1 = $User1_name.' '. $User1_passw; $User2_name = 'metallica'; $User2_passw = 'baker'; $user2 = $User2_name.' '. $User2_passw; $User3_name = 'coldplay'; $User3_passw = 'adam'; $user3 = $User3_name.' '. $User3_passw; $User4_name = 'rowland'; $User4_passw = 'blue'; $user4 = $User4_name.' '. $User4_passw; $User5_name = 'moby'; $User5_passw = 'october'; $user5 = $User5_name.' '. $User5_passw; // end of list //Begin validation code if($username == "$user1"){ $validated = true; } else if($username == "$user2"){ $validated = true; } else if($username == "$user3"){ $validated = true; } else if($username=="$user4"){ $validated = true; } else if($username=="$user5"){ $validated = true; } //end validation code if($validated){ print("welcome, $user.; else{ print("invalid username/password combination, please try again."); } ?> </head> <body> <FORM name="form1" method="post" action="basicFormex1.php"> <input type="text" name="username" value="<?php print $username;?>"> <input type="password" name="password" value="<?php print $password;?>"> <input type="submit" name="Submit2" value="Display"> </FORM> </body> </html>
March 01, 2012 06:46AM | Admin Registered: 7 years ago Posts: 5,213 |
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes March 01, 2012 06:00PM | Registered: 1 year ago Posts: 100 |
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes March 02, 2012 01:41PM | Registered: 1 year ago Posts: 88 |
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes March 02, 2012 09:18PM | Registered: 1 year ago Posts: 41 |
|
Re: PHP Four - Working with HTML Forms - PHP and HTML Checkboxes March 02, 2012 10:34PM | Registered: 1 year ago Posts: 41 |
</head>Language: PHP<?PHP if (isset($_POST['Submit1'])) { $username = $_POST['username']; $password = $_POST['password']; if ($username =="Letmein" && $password =="aeRials") { print ("Welcome back, letmein!"); } else if ($username =="gEorgia" && $password =="vIx") { print ("Welcome back, gEorgia!"); } else if ($username =="Pieter" && $password =="piErs") { print ("welcome back, pieter!"); } else if ($username =="Paul" && $password =="plIers") { print ("welcome back, paul!"); } else if ($username =="Greg" && $password =="spanNer") { print ("Welcome back, greg!"); } else if ($username =="Gary" && $password =="lOcknut") { print ("Welcome back, gary!"); } else { print ("You're not a member of this site, please create a new profile!"); } } ?>

