I have a question, I have a page and a form that I direct it to itself to edit data to database.
I need a way to use the form and redirect itself with action=editcinemas.php?cinema_id=THE ID OF CINEMA
<html>
<body>
<form name="form3" method="post" action="editcinemas.php"> //MY PROBLEM IS HERE I GUESS
<td>
<table>
<?php
require('../classes/cinema_class.php');
$cinema=new cinema($_GET["cinema_id"]);
$cinemas = $cinema->get_all_cinemas();
foreach ($cinemas as $movie)
{
$cinema_id = $movie['cinema_id'];
$cinema_name = $movie['cinema_name'];
$cinema_location = $movie['cinema_location'];
}
echo "<input name='cinemaid' type='hidden' id='cinemaid' value=" . $cinema_id . '><br/>';
echo "Cinema Name :";
echo "<input name='cinemaname' type='text' id='cinemaname' value=" . $cinema_name . '><br/>';
echo "Cinema Location :";
echo "<input name='cinemalocation' type='text' id='cinemalocation' value=" . $cinema_location . '><br/>';
?>
</table>
<input type="submit" name="Edit" value="Edit"> <input type="reset" name="Reset" value="Reset"/><INPUT Type="button" VALUE="Back" onClick="history.go(-1);return true;">
</form>
</body></html>
<?php
$cinemaid=$_POST['cinemaid'];
$cinemaname=$_POST['cinemaname'];
$cinemalocation=$_POST['cinemalocation'];
if ($_POST) {
if(empty($cinemaname)){
echo "Cinema Name is a must"; }
else{
$update_movie=mysql_query("UPDATE `memoire`.`cinema`
SET `cinema_name`= '$cinemaname', `cinema_location`= '$cinemalocation'
WHERE `cinema_id`='$cinemaid'");
if($update_movie)
{ header("Refresh: 0;url=../listallcinemas.php");}
else
{ echo "error in registration".mysql_error(); }
}
?>
Just simply append it, like this:
<form name="form3" method="post" action="editcinemas.php?cinema_id=<?php echo $_GET["cinema_id"]; ?>">
Related
So, I'm making a PHP page. I'm trying to get a url like this
https://nikkiedev.com/folder/indexfile/?schedule-btn=true&time-zone=CET
but instead, when I click on my GET form for the time zone it goes to
https://nikkiedev.com/folder/indexfile/?time-zone=CET
Here's my code:
<div class='mobile-center'>
<form method="GET">
<button name="schedule-btn" type="submit" value="true" class="btn">schedule</button>
<button name="roles-btn" type="submit" value="true" class="btn">roles</button>
</form>
<?php
$sched_btn = $_GET["schedule-btn"];
$roles_btn = $_GET["roles-btn"];
if (isset($sched_btn)) {
echo "<div class='mobile-center'>";
echo "<h1>Change schedule</h1>";
echo "<hr>";
echo "<p>Choose time zone</p>";
echo "<form method='GET'>";
echo "<p>
<input type='radio' name='time-zone' value='CET'> CET
<input type='radio' name='time-zone' value='EST'> EST
<input type='submit'>
</p>";
echo "</form>";
$timezone = $_GET["time-zone"];
echo "</div>";
if ($timezone == "CET") {
echo "<h1>CET</h1>";
}
else if ($timezone == "EST") {
echo "<h1>EST</h1>";
}
}
?>
</div>
Add the value of $sched_btn as a hidden input in the new form.
if (isset($sched_btn)) {
echo "<div class='mobile-center'>";
echo "<h1>Change schedule</h1>";
echo "<hr>";
echo "<p>Choose time zone</p>";
echo "<form method='GET'>";
echo "<input type='hidden' name='schedule-btn' value='$sched_btn'>";
echo "<p>
<input type='radio' name='time-zone' value='CET'> CET
<input type='radio' name='time-zone' value='EST'> EST
<input type='submit'>
</p>";
echo "</form>";
$timezone = $_GET["time-zone"];
echo "</div>";
if ($timezone == "CET") {
echo "<h1>CET</h1>";
}
else if ($timezone == "EST") {
echo "<h1>EST</h1>";
}
}
while($row = mysql_fetch_assoc($req))
{
$user_from = $row['user_from'];
echo "<form method='post'><a href='".$row['user_from']."' name='yo' value'".$row['user_from']."'>".$row['user_from']."</a>  ";
echo "<input type='submit' name='acc' value='Accept'>   <input type='submit' name='cancel' value='Reject Rrquest'></form> <br/><br/>";
}
if(isset($_POST['acc']))
{
}
Blockquote
//on submit here i need to disply corresponding $row['user_from']
value
Use <input type="hidden" name="whateveryouwant" />, if you don't want to display text field to user.
Try this:
while($row = mysql_fetch_assoc($req))
{
$user_from = $row['user_from'];
echo "<form method='post'><input type='hidden' name='user_from' value='".$row['user_from']."' /><a href='".$row['user_from']."' name='yo' value'".$row['user_from']."'>".$row['user_from']."</a>  ";
echo "<input type='submit' name='acc' value='Accept'>   <input type='submit' name='cancel' value='Reject Rrquest'></form> <br/><br/>";
}
if(isset($_POST['acc']))
{
echo $_POST['user_from'];//echo the value of user_form
}
<?php
while($row = mysql_fetch_assoc($req))
{
$user_from = $row['user_from'];
?>
<form method="post" action="">
<?php $row['user_from'] ?>
<input type="submit" name="acc" value="Accept">
<input type="submit" name="cancel" value="Reject Rrquest">
</form>
<php
}
?>
<?php
if(isset($_POST['acc']) && !empty($_POST['yo']))
{
$link = $_POST['yo'];
// do what you want to do with this `url`
}
?>
NOTE: Don't Complex Your Code With Using Html COde In Php echo. You Can Just Open the While Loop Brackets { and then close the php ?> then simple html you have to written, So Just Avoid to used html code inside the php echo
I'm working on a form validation and I'm currently doing some debugging on my code. I'll insert the necessary code snippets below:
Form code:
echo '<h1> Seismic Recording </h1>
<div>
<form action="validate2.php" method="POST">';
echo "Latitude: <input type='text' name='latitude'>";
echo "Longitude: <input type='text' name='longitude'required>";
echo 'Wave Type: <select id="wave_type" name="wave_type" required>
<option selected value="s">S</option>
<option value="p">P</option>
<option value="surface_wave">Surface Wave</option>
</select>';
echo "Wave Value: <input type='text' name='wave_value' required>";
echo 'Upload CSV File: <input type="file" name="file">';
echo " <input type='submit' name='submit' value='submit'>";
echo "</form>
</div> ";
Validation code:
echo "w";
if (isset($_POST['submit'])) {
echo "t";
$latitude = $_POST['latitude'];
if ($latitude == NULL) {
echo "Please insert a latitude . <br>";
$error = $error + 1;
}
}
echo "q";
The form validations that I've put within the if statement doesn't work. I tried debugging the code by inserting the 'echo "q"' and 'echo "w"' to see where the problem lies. Those statements work (they output the characters). But the 'echo "t"' within the if statement doesn't work. Why is that so?
Result of var_dump($_POST):
array(5) { ["latitude"]=> string(0) "" ["longitude"]=> string(1) "g"
["wave_type"]=> string(1) "s" ["wave_value"]=> string(1) "g"
["file"]=> string(0) "" }
My issue isn't so much in getting the latitude to validate but why doesn't the 'echo t' work?
Why check for a 'submit' post variable when you're working with latitude?
if(isset($_POST['latitude']))
{
echo "t";
$latitude=$_POST['latitude'];
}
else
{
echo "Please insert a latitude . <br>";
$error = $error + 1;
}
Also there is no need for a name on the submit button
<input type="submit" value="Submit">
You just have your form rendering messed up, this works:
echo "<h1> Seismic Recording </h1>";
echo "<div>";
echo "<form action='' method='POST'>";
echo "Latitude: <input type='text' name='latitude'>";
echo "Longitude: <input type='text' name='longitude'd>";
echo 'Wave Type: <select id="wave_type" name="wave_type">';
echo '<option selected value="s">S</option>';
echo '<option value="p">P</option>';
echo '<option value="surface_wave">Surface Wave</option>';
echo "</select>";
echo "Wave Value: <input type='text' name='wave_value' d>";
echo 'Upload CSV File: <input type="file" name="file">';
echo "<input type='submit' name='submit' value='submit'>";
echo "</form>";
echo "</div>";
if(isset($_POST)){
if(isset($_POST['submit'])){
echo "Submit is alive!!";
}
}
In order to avoid this kind of issues, remember that you can just write plain html, on this way:
<?php
//Mi php code blablabla
?>
/* My html code */
<h1>Wonderful day, isn't it?<h1>
<?php
//Another php tasks and etc
?>
<!--form code start-->
<?php
if(isset($_REQUEST['req']))
{
echo "Please enter any input";
}
?>
<form action="validate2.php" method="POST">
Latitude: <input type='text' name='latitude'>
<input type='submit' name='submit' value='submit'>
</form>
<!--validate2.php code start-->
<?php
if (isset($_POST['submit']))
{
$latitude = $_POST['latitude'];
if ($latitude == NULL)
{
header("Location:frm.php?req=error");
}
else
{
echo "Your input Text is: ".$latitude;
}
}
?>
<!--Second Method-->
<!--form code start-->
<form action="validate2.php" method="POST">
Latitude: <input type='text' name='latitude'>
<input type='submit' name='submit' value='submit'>
</form>
<!--validate2.php code start-->
<?php
if (isset($_POST['submit']))
{
$latitude = $_POST['latitude'];
if ($latitude == NULL)
{
echo '<script>alert("Please enter any input");
window.location.href="frm.php";</script>';
}
else
{
echo "Your input Text is: ".$latitude;
}
}
?>
Try this:-
$curl_connection =
curl_init('http://www.domainname.com/target_url.php');
link:-http://www.html-form-guide.com/php-form/php-form-submit.html
I have a form on a page like:
<form action='search.php' method='POST'>
<input type='text' name='specialist' />
<input type='submit' name='submit' />
</form>
on search page there is another form like
<form action='' method='POST'>
<input type='submit' name='anygender' />
</form>
then i am using
if(isset($_POST['anygender'])){
$speciality = $_POST['speciality'];
echo $speciality;
$a = mysql_query("SELECT * FROM find_doctor WHERE doctor_type LIKE '%$speciality%'");
while ($b = mysql_fetch_array($a)){
echo "<img src='$b[image]' height='150px' width='300px'>"."</br>";
echo $b['name']."</br>";
echo $b['doctor_type']."</br>";
echo $b['location']."</br>";
echo $b['insurance']."</br>";
echo $b['comments']."</br>";
echo $b['address']."</br>";
}
}
then $specialist is showing blank and sql query not working..I want to use both form's post value together.Please tell me how to use first form post value in this. Thanks in advance
Why you need two forms?
<form action='index.php' method='POST'>
<input type='text' name='specialist' />
<input type='submit' name='anygender' />
<input type='submit' name='submit' />
</form>
Maybe you can use one form and check buttom?
Use this code. Check $_POST['submit'] in if condition.
if(isset($_POST['submit'])){
$speciality = $_POST['speciality'];
echo $speciality;
$a = mysql_query("SELECT * FROM find_doctor WHERE doctor_type LIKE '%$speciality%'");
while ($b = mysql_fetch_array($a)){
echo "<img src='$b[image]' height='150px' width='300px'>"."</br>";
echo $b['name']."</br>";
echo $b['doctor_type']."</br>";
echo $b['location']."</br>";
echo $b['insurance']."</br>";
echo $b['comments']."</br>";
echo $b['address']."</br>";
}
}
EDIT: Apologies - all code now pasted below
Apologies for the first time newbie question - I've been looking for an answer here and on google - I get the feeling this is some simple coding i'm messing up.
I've created a form which, when you validate, you check all the data on the same page and the original data is kept in the original form so you can make changes if you wish.
I have a section of the form where this doesn't work however - where you can ask multiple questions and each question can have up to 4 answers.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<head>
<title>Test page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="stylenewtest.css" type="text/css" />
<script language="javascript" src="tableadd.js"></script>
</head>
<body>
<?php
$string = isset($_POST['quiz_format']) ? $_POST['quiz_format'] : false;
$quiz_format = ereg_replace("[^0-9a-zA-Z?ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\. ]", "", $string);
$stringquiz_100 = isset($_POST['quiz_100']) ? $_POST['quiz_100'] : false;
$quiz_100 = ereg_replace("[^0-9a-zA-Z?ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\. ]", "", $stringquiz_100);
$stringquiz_fback = isset($_POST['quiz_fback']) ? $_POST['quiz_fback'] : false;
$quiz_fback = ereg_replace("[^0-9a-zA-Z?ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\. ]", "", $stringquiz_fback);
$stringquiz_title = isset($_POST['quiz_title']) ? $_POST['quiz_title'] : false;
$quiz_title = ereg_replace("[^0-9a-zA-Z?ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\. ]", "", $stringquiz_title);
$stringquiz_instruct = isset($_POST['quiz_instruct']) ? $_POST['quiz_instruct'] : false;
$quiz_instruct = ereg_replace("[^0-9a-zA-Z?ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\?,\"\'\._#\\/ !&()=\+;:\t\r\n-]", "", $stringquiz_instruct);
$stringquiz_time = isset($_POST['quiz_time']) ? $_POST['quiz_time'] : false;
$quiz_time = ereg_replace("[^0-9a-zA-Z?ąćęłńóśżźĄĆĘŁŃÓŚŻŹ\. ]", "", $stringquiz_time);
?>
<div id="content">
<p><span class="error">* required field.</span></p>
<form method="post" action="">
<div class="datagrid">
<table>
<tr><th colspan="2">Please choose the format of the quiz<span class="error">*</span></th></tr>
<tr><td>Hangman</td><td><input type="radio" name="quiz_format" <?php if (isset($quiz_format) && $quiz_format=="Hangman") echo "checked";?> value="Hangman"></td></tr>
<tr><td>Gap fill</td><td><input type="radio" name="quiz_format" <?php if (isset($quiz_format) && $quiz_format=="Gap fill") echo "checked";?> value="Gap fill"></td></tr>
<tr><td>Multiple choice</td><td><input type="radio" name="quiz_format" <?php if (isset($quiz_format) && $quiz_format=="Multiple Choice") echo "checked";?> value="Multiple choice"></td></tr>
<tr><td>Simple Q & A</td><td><input type="radio" name="quiz_format" <?php if (isset($quiz_format) && $quiz_format=="Simple Q & A") echo "checked";?> value="Simple Q & A"></td></tr>
<tr><td>Word formation hangman</td><td><input type="radio" name="quiz_format" <?php if (isset($quiz_format) && $quiz_format=="Word formation hangman") echo "checked";?> value="Word formation hangman"></td></tr>
</table>
</div>
<br />
<div class="datagrid">
<table>
<tr><th colspan="2">Continue repeating the exercise until 100% achieved?<span class="error">*</span></th></tr>
<tr><td>Yes</td><td><input type="radio" name="quiz_100" <?php if (isset($quiz_100) && $quiz_100=="Yes") echo "checked";?> value="Yes"></td></tr>
<tr><td>No</td><td><input type="radio" name="quiz_100" <?php if (isset($quiz_100) && $quiz_100=="No") echo "checked";?> value="No"></td></tr>
</table>
</div>
<br />
<div class="datagrid">
<table>
<tr><th colspan="2">Show the answer as correct/incorrect after every question or just at the end?<span class="error">*</span></th></tr>
<tr><td>After every question</td><td><input type="radio" name="quiz_fback" <?php if (isset($quiz_fback) && $quiz_fback=="After every question") echo "checked";?> value="After every question"></td></tr>
<tr><td>Just at the end</td><td><input type="radio" name="quiz_fback" <?php if (isset($quiz_fback) && $quiz_fback=="Just at the end") echo "checked";?> value="Just at the end"></td></tr>
</table>
</div>
<br />
<div class="datagrid">
<table>
<tr><th colspan="2">Please enter in the title of the quiz<span class="error">*</span></th></tr>
<tr><td>Quiz title:</td><td><input type="text" name="quiz_title" value="<?php echo $_POST[quiz_title];?>"></td></tr>
</table>
<br />
<table>
<tr><th colspan="2">Please enter in the instructions for the quiz<span class="error">*</span></th></tr>
<tr><td>Quiz instructions:</td><td><textarea name="quiz_instruct" rows="10" cols="40"><?php echo $_POST[quiz_instruct];?></textarea></td></tr>
</table>
</div>
<br />
<div class="datagrid">
<script language="javascript">
window.onload = moreFields;
window.onload = init;
</script>
<table>
<tr><th colspan="5">Please enter in the quiz's questions and answers:<span class="error">*</span></th></tr>
</table>
<div id="readroot" style="display: none">
<input type="button" value="Remove a question field"
onclick="this.parentNode.parentNode.removeChild(this.parentNode);" />
<table>
<tr>
<td>Question:</td>
<td colspan="3"><input type="text" name="q[]" value="<?php echo $_POST['q'][$i] ?>"></td>
</tr>
<tr>
<td>Answer 1:</td>
<td>Answer 2:</td>
<td>Answer 3:</td>
<td>Answer 4:</td>
</tr>
<tr>
<td><input type="text" name="a1[]" value="<?php echo $_POST['a1'][$i] ?>"></td>
<td><input type="text" name="a2[]" value="<?php echo $_POST['a2'][$i] ?>"></td>
<td><input type="text" name="a3[]" value="<?php echo $_POST['a3'][$i] ?>"></td>
<td><input type="text" name="a4[]" value="<?php echo $_POST['a4'][$i] ?>"></td>
</tr>
</table>
</div>
<span id="writeroot"></span><input type="button" id="moreFields" value="Click here to add further question fields" /><br />
</div>
<br />
<div class="datagrid">
<table>
<tr><td><input type="submit" name="Submit1" value="Submit"/></td></tr>
</table>
</div>
</form>
<?php
if ( isset( $_POST['Submit1'] ) ) {
echo "<form method=post action=insert.php>";
echo "<h1>Please confirm the quiz details are correct</h1>";
echo "<div class=datagrid>";
echo "<table>";
if(empty($string)){
echo("<tr><td>Quiz format:</td><td><h3>Please go back and choose a quiz format<h3></td></tr>");
$showbutton=1;
}
else{
echo("<tr><td>Quiz format:</td><td>" . $quiz_format . "</td></tr>");
echo("<input type=hidden name=quiz_format value='" . $quiz_format . "' />");
}
if(empty($stringquiz_100)){
echo("<tr><td>Continue repeating the exercise until a 100% score is achieved?:</td><td><h3>Please go back and choose an option<h3></td></tr>");
$showbutton=1;
}
else{
echo("<tr><td>Continue repeating the exercise until a 100% score is achieved?:</td><td>" . $quiz_100 . "</td></tr>");
echo("<input type=hidden name=quiz_100 value='" . $quiz_100 . "' />");
}
if(empty($stringquiz_100)){
echo("<tr><td>Do you want the answer to be shown after every question or at the end of the quiz?:</td><td><h3>Please go back and choose an option<h3></td></tr>");
$showbutton=1;
}
else{
echo("<tr><td>Do you want the answer to be shown after every question or at the end of the quiz?:</td><td>" . $quiz_fback . "</td></tr>");
echo("<input type=hidden name=quiz_fback value='" . $quiz_fback . "' />");
}
echo "</table>";
echo "</div>";
echo "<br />";
echo "<div class=datagrid>";
echo "<table>";
if(empty($stringquiz_title)){
echo("<tr><td>Quiz title:</td><td><h3>Please go back and enter in a title for the quiz</h3></td></tr>");
$showbutton=1;
}
else{
echo("<tr><td>Quiz title:</td><td>" . $quiz_title . "</td></tr>");
echo("<input type=hidden name=quiz_title value='" . $quiz_title . "' />");
}
if(empty($stringquiz_instruct)){
echo("<tr><td>Quiz instructions:</td><td><h3>Please go back and enter in instructions for the quiz</h3></td></tr>");
$showbutton=1;
}
else{
echo("<tr><td>Quiz instructions:</td><td>" . $quiz_instruct . "</td></tr>");
echo("<input type=hidden name=quiz_instruct value='" . $quiz_instruct . "' />");
}
echo "</table>";
echo "</div>";
echo "<br />";
echo "<div class=datagrid>";
echo "<table>";
if(empty($stringquiz_time)){
echo("<tr><td>Time limit:</td><td>not specified</td></tr>");
}
else
{
echo("<tr><td>Time limit:</td><td>" . $quiz_time . "</td></tr>");
echo("<input type=hidden name=quiz_time value='" . $quiz_time . "' />");
}
echo "</table>";
echo "</div>";
echo "<br />";
echo "<div class=datagrid>";
echo "<table>";
echo "<tr><td colspan=5>The questions and answers to your quiz:</td></tr>";
$aq = $_POST['q'];
$aa1 = $_POST['a1'];
$aa2 = $_POST['a2'];
$aa3 = $_POST['a3'];
$aa4 = $_POST['a4'];
$N = count($aq);
for($i=1; $i < $N; $i++){
if($aq[$i]==""){
echo("<tr><td>Question:</td><td><h3>Please go back and enter a question</h3></td></tr>");
$showbutton=1;
}
elseif($aa1[$i]==""){
echo("<tr><td>Answer:</td><td><h3>Please go back and enter at least one answer</h3></td></tr>");
$showbutton=1;
}
else{
echo ("<table><tr><td>Question:</td><td colspan=3>" . $aq[$i]. "<input type=hidden name=q[] value='" . $aq[$i] . "'></td></tr>
<tr><td>Answer 1:</td><td>Answer 2:</td><td>Answer 3:</td><td>Answer 4:</td></tr>
<tr><td>" .$aa1[$i] . " <input type=hidden name=a1[] value='" .$aa1[$i] . "'></td>
<td>" .$aa2[$i] . " <input type=hidden name=a2[] value='" .$aa2[$i] . "'></td>
<td>" .$aa3[$i] . " <input type=hidden name=a3[] value='" .$aa3[$i] . "'></td>
<td>" .$aa4[$i] . " <input type=hidden name=a4[] value='" .$aa4[$i] . "'></td> </tr></table>");
}
}
echo "</table>";
echo "</div>";
echo "<br />";
echo "<div class=datagrid>";
echo "<table>";
echo "<tr><td><input type=button value='<< Go Back' onclick='goBack()' /></td></tr>";
if ($showbutton =="1"){
}
else{
echo "<tr><td><input type=submit value=Submit></td></tr>";
echo "</table>";
echo "</form>";
}
}
?>
</div>
</body>
</html>
but every time I submit, the questions and answers carry through but the form fields lose all the data. How can I keep the data in the fields?
Many thanks in advance
You can simply set the value of the input to either $_POST['old_value_name] or $_GET['old_value_name'] depending on which form method you are using. Therefore, your new code would look something like this (assuming that you are looking for the key $i from your question):
<table>
<tr>
<td>Question:</td>
<td colspan="3"><input type="text" name="q[]" value="<?php echo $_POST['q'][$i] ?>"></td>
</tr>
<tr>
<td>Answer 1:</td>
<td>Answer 2:</td>
<td>Answer 3:</td>
<td>Answer 4:</td>
</tr>
<tr>
<td><input type="text" name="a1[]" value="<?php echo $_POST['a1'][$i] ?>"></td>
<td><input type="text" name="a2[]" value="<?php echo $_POST['a2'][$i] ?>"></td>
<td><input type="text" name="a3[]" value="<?php echo $_POST['a3'][$i] ?>"></td>
<td><input type="text" name="a4[]" value="<?php echo $_POST['a3'][$i] ?>"></td>
</tr>
</table>
As far as I've understood your problem you want to keep values in a form after they were sent to server. "I've created a form which, when you validate, you check all the data on the same page and the original data is kept in the original form so you can make changes if you wish"
It's ok. I remember I wanted the same a few months ago. This is why I tried to help.
There is only a problem that after pressing "submit" button form is sent to server and page is reloaded.
In return you get a new page from webserver which you pointed in the form field "action".
I would do it so:
Target form: <br/>
<form id="target" action="index.php" method='post'>
<input name="first_field" type="text" value="<?php if ( isset($_POST['first_field']) )
echo $_POST['first_field']; ?>" /> <br/>
<input name="second_field" type="text" value="<?php if ( isset($_POST['second_field']))
echo $_POST['second_field'];?>" /> <br/>
<p><b>What kind of girls do you like?:</b><Br>
<input type="radio" name="browser" value="brunette" <?php if( $_POST['browser']==="brunette" ) echo "checked"; ?> > brunette<Br>
<input type="radio" name="browser" value="blonde" <?php if( $_POST['browser']==="blonde" ) echo "checked"; ?> > blonde<Br>
<input type="radio" name="browser" value="red" <?php if( $_POST['browser']==="red" ) echo "checked"; ?> > red<Br>
</p>
<input type="submit" />
</form>
Any ideas how it can be changed/improved are encouraged.