IT Community - Software Programming, Web Development and Technical Support

Form Examples in PHP

This is a discussion on Form Examples in PHP within the PHP Programming forums, part of the Web Development category; Form Examples in PHP <HTML> <BODY> <FORM METHOD="POST" ACTION="getformvalue.php&...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > PHP Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 11-09-2007, 05:25 AM
varghese varghese is offline
D-Web Programmer
 
Join Date: Feb 2007
Posts: 93
varghese is on a distinguished road
Default Form Examples in PHP

Form Examples in PHP
<HTML>
<BODY>
<FORM METHOD="POST" ACTION="getformvalue.php">
<H2>Contact List</H2>
<BR>Name:
<BR><INPUT TYPE="TEXT" NAME="Nickname">
<BR>
<BR>Address:
<BR><INPUT TYPE="TEXT" NAME="Fullname">
<BR>
<BR>ContactNo:
<BR><TEXTAREA NAME="Memo" ROWS="4" COLS="40" WRAP="PHYSICAL">
</TEXTAREA>
<BR>
<BR>
<INPUT TYPE="SUBMIT">
</FORM>
</BODY>


<!-- getformvalue.php
<?php
echo "<BR>Nickname=$Name";
echo "<BR>Fullname=$Address";
echo "<BR>Memo=$ContactNo";
?>
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-09-2007, 11:33 PM
varghese varghese is offline
D-Web Programmer
 
Join Date: Feb 2007
Posts: 93
varghese is on a distinguished road
Default Re: Form Examples in PHP

Form Checkbox
<html>
<head>
<title>Checkbox Demo</title>
</head>
<body>
<h1>Checkbox Demo</h1>

<h3>Demonstrates checkboxes</h3>
<form action ="HandleFormCheckBox.php">

<ul>
<li><input type ="checkbox" name ="chkFries" value ="11.00">Fries</li>
<li><input type ="checkbox" name ="chkSoda" value ="12.85">Soda</li>
<li><input type ="checkbox" name ="chkShake" value ="1.30">Shake</li>
<li><input type ="checkbox" name ="chkKetchup" value =".05">Ketchup</li>
</ul>
<input type ="submit">
</form>

</body>
</html>


<!-- HandleFormCheckBox.php
<html>
<head>
<title>Checkbox Demo</title>
</head>
<body>
<h3>Demonstrates reading checkboxes</h3>
<?
print <<<HERE
chkFries: $chkFries <br>
chkSoda: $chkSoda <br>
chkShake: $chkShake <br>
chkKetchup: $chkKetchup <br>
<hr>

HERE;

$total = 0;

if (!empty($chkFries)){
print ("You chose Fries <br>");
$total = $total + $chkFries;
}

if (!empty($chkSoda)){
print ("You chose Soda <br>");
$total = $total + $chkSoda;
}

if (!empty($chkShake)){
print ("You chose Shake <br>");
$total = $total + $chkShake;
}

if (!empty($chkKetchup)){
print ("You chose Ketchup <br>");
$total = $total + $chkKetchup;
}

print "The total cost is \$$total";

?>
</body>
</html>
-->
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-09-2007, 11:41 PM
varghese varghese is offline
D-Web Programmer
 
Join Date: Feb 2007
Posts: 93
varghese is on a distinguished road
Default Re: Form Examples in PHP

Form Email
<html>
<head>
<title>Simple Send Mail Form</title>
</head>
<body>
<h1>Mail Form</h1>
<form name="form1" method="post" action="SimpleEmail.php">
<table>
<tr><td><b>To</b></td><td><input type="text" name="mailto" size="35"></td></tr>
<tr><td><b>Subject</b></td>
<td><input type="text" name="mailsubject" size="35"></td></tr>
<tr><td><b>Message</b></td>
<td><textarea name="mailbody" cols="50" rows="7"></textarea></td>
</tr>
<tr><td colspan="2">
<input type="submit" name="Submit" value="Send">
</td>
</tr>
</table>
</form>
</body>
</html>


<!-- SimpleEmail.php
<?php
if (empty ($mailto) ) {
die ( "Recipient is blank! ") ;
}

if (empty ($mailsubject) ){
$mailsubject=" " ;
}

if (empty ($mailbody) ) {
$mailbody=" " ;
}

$result = mail ($mailto, $mailsubject, $mailbody) ;

if ($result) {
echo "Email sent successfully!" ;
}else{
echo "Email could not be sent." ;
}
?>
-->
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-13-2007, 03:14 AM
bermuda bermuda is offline
D-Web Trainee
 
Join Date: Oct 2007
Posts: 10
bermuda is on a distinguished road
Default Re: Form Examples in PHP

It would really be great if you could also provide the codes for embedding a simple, not too complex, captcha into the forums. Thanks.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-13-2007, 09:43 PM
vims vims is offline
D-Web Programmer
 
Join Date: Oct 2007
Posts: 67
vims is on a distinguished road
Wink Re: Form Examples in PHP

Form Data - Dealing with Array Data

<HTML>
<BODY>
<FORM METHOD="POST" ACTION="DealWithArrayFormData.php">
<H1>Contact Information</H1>
<TABLE>
<TR>
<TD>Childrens' Names:</TD>
</TR>
<TR>
<TD><INPUT TYPE="TEXT" NAME="children[]"></TD>
</TR>
<TR>
<TD><INPUT TYPE="TEXT" NAME="children[]"></TD>
</TR>
<TR>
<TD><INPUT TYPE="TEXT" NAME="children[]"></TD>
</TR>
<TR>
<TD><INPUT TYPE="TEXT" NAME="children[]"></TD>
</TR>
<TR>
<TD><INPUT TYPE="TEXT" NAME="children[]"></TD>
</TR>
</TABLE>
<BR>
<BR>
<BR>
<INPUT TYPE="SUBMIT" VALUE="Submit">
<BR>
<BR>
<INPUT TYPE="RESET" VALUE="Clear the Form">
</FORM>
</BODY>
</HTML>

<!-- DealWithArrayFormData.php

<?php
foreach ($children as $index => $child){
echo "<BR>child[$index]=$child";
}
echo "<BR>";

sort($children);

foreach ($children as $index => $child){
echo "<BR>child[$index]=$child";
}
?>
-->
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-14-2007, 10:17 PM
vims vims is offline
D-Web Programmer
 
Join Date: Oct 2007
Posts: 67
vims is on a distinguished road
Wink Re: Form Examples in PHP

Radio buttons examples

It is used to select anyone of the input from several inputs. That is selection of one from many choices.

Code:
<HTML>
<HEAD>
<TITLE>Candy preference form</TITLE>
</HEAD>
   
<BODY>
<FORM ACTION="SelectFormControlHandler.php" METHOD="POST">
What's your most favorite kind of candy?<BR>
<INPUT TYPE="radio" NAME="Candy" VALUE="peanut butter cups">Peanut butter cups<BR>
<INPUT TYPE="radio" NAME="Candy" VALUE="Snickers">Snickers<BR>
<INPUT TYPE="radio" NAME="Candy" VALUE="Turtles">Turtles<BR>
<INPUT TYPE="submit">
</FORM>
</BODY>
</HTML>


<!-- SelectFormControlHandler.php
<HTML>
<HEAD>
<TITLE>Candy preference reply</TITLE>
</HEAD>
   
<BODY>
Yum, <?php print("$Candy!  ");
if($Candy == "peanut butter cups"){
  print("peanut butter cups");
  print(" $Candy.");
}else{
  print("$Candy");
  if($Candy == "Snickers"){
    print("Snickers");
  }elseif($Candy == "Turtles"){
    print("Turtles");
  }
}
?>
</BODY>
</HTML>
-->
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 11-14-2007, 10:19 PM
vims vims is offline
D-Web Programmer
 
Join Date: Oct 2007
Posts: 67
vims is on a distinguished road
Wink Re: Form Examples in PHP

Form Select - Select button examples

Code:
<html>
<head>
<title>An HTML form including a SELECT element</title>
</head>
<body>
<form action="formSelectData.php" method="POST">
  <input type="text" name="user">
  <br>
  <textarea name="address" rows="5" cols="40"></textarea>
  <br>
  <select name="products[]" multiple>
    <option>option1
    <option>option2
    <option>option3
    <option>option4
  </select>
  <br>
  <input type="submit" value="OK">
</form>
</body>
</html>

<!-- formSelectData.php

<html>
<head>
<title>Reading input from the form</title>
</head>
<body>
<?php
print "Welcome <b>$user</b><p>\n\n";
print "Your address is:<p>\n\n<b>$address</b><p>\n\n";
print "Your product choices are:<p>\n\n";
print "<ul>\n\n";
foreach ( $products as $value ){
    print "<li>$value<br>\n";
}
print "</ul>";
?>
</body>
</html>


-->
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP with Mysql examples varghese PHP Programming 2 11-19-2007 07:13 AM
PHP functions and examples varghese PHP Programming 7 11-19-2007 07:02 AM
Create a php function examples varghese PHP Programming 0 11-19-2007 07:00 AM
HTML and CSS examples varghese HTML, CSS and Javascript Coding Techniques 0 11-09-2007 04:33 AM
Examples in SQL/MYSQL varghese Database Support 0 11-09-2007 04:10 AM


All times are GMT -7. The time now is 12:31 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0