PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Old October 3rd, 2003, 06:23 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,308 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 30
Clear Contents of registration form

How do I clear all the text areas of my submitted form.Each time i refresh the page the form is reinserted into the database.I tried reset does not work.I cannot use Javascript.Has to be in pHP

Please help

Reply With Quote
Old October 3rd, 2003, 06:26 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 10
RE: Clear Contents of registration form

it sounds like the form is repopulating with the inserted data...post the code so we can take a look...

Reply With Quote
Old October 3rd, 2003, 06:36 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,308 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 30
RE: Clear Contents of registration form

require_once ('functions.php');
require_once ('config.php');
include ('style.html');
$valid = TRUE;
//print "<input type="reset" class="reset" value="Clear">n";
print "<input type="reset" value= "Clear_form">n";



if (isset ($_POST['submit'])) {
foreach($_POST as $key=>$value) {
$$key = $value;
}

$valid = $fn = checkLength($fname, 1, 30);
$ln = checkLength($lname, 1, 30);
$valid = $valid && $ln;
$em = checkEmail($email);
$valid = $valid && $em;
$ps = checkPassword($password);
$valid = $valid && $ps;
$ps2 = $password == $password2;
$valid = $valid && $ps2;


if ($valid) {
database connection
switch($title)
{
case "X":
$query2="INSERT INTO X(username,firstname,lastname,middleinitial,phone, address1,address2,city,state,country,zip,Category) VALUES ('$email','$fname','$lname','$middleinitial','$pho ne','$address1','$address2','$city','$State','$cou ntry','$zipcode','$category')";
$result2 = mysql_query($query2, $db);
if($result2){
$query="INSERT INTO test (username, pass,level) VALUES ('$email','$password','3')";
$result = mysql_query($query, $db);
print($query);
echo mysql_affected_rows().'answers inserted into database n';
echo "Form filled successfully!";
}
else
echo 'could not insert into database';
print($query2);
break;
case "Y":
$query5="INSERT INTO Y(firstname,middleinitial,lastname,email,address1, address2,city,state,country,zip,phone) VALUES ('$fname','$middleinitial','$lname','$email','$add ress1','$address2','$city','$State','$country','$z ipcode','$phone')";
$result5 = mysql_query($query5, $db);
print($query5);
if($result5){
$query6="INSERT INTO test (username, pass,level) VALUES ('$email','$password','4')";
$result6 = mysql_query($query6, $db);
print($query6);
echo mysql_affected_rows().'answers inserted into database n';
echo "Form filled successfully!";
}
else
echo 'could not insert into database';
break;
}
}
}
else {
$fn = $ln = $em = $ps = $ps2 = $zp = TRUE;
$fname = $lname = $email = $zipcode = '';

}


?>
<h1>Sample Registration Form</h1>
<A HREF="previous.html" onClick="history.back();return false;">Go back</A>
<?php
if (!$valid) {
?>
<style type="text/css">
td.error {color:C03; font-weight:bold; }
</style>
Please correct the items in red and resubmit.<br /><br />
<?php
}
?>
<form method="POST" action="reg.php">
<table border="0">
<tr>
<td colspan="2">Please fill out the form for registration.<br /><br />
Passwords should be a minimum of 8 characters.<br />
They should be composed of numbers and letters with a number<br />
somewhere in the middle. Please avoid using the same<br />
character repeatedly.<br /><br />
</b><br /><br /></td>
</tr>
<tr>
<td align="right"
</td>
Title:
<td>
<select name="title" size=1 style= "background-color: #FFFFFF; color:red;">

<option value="r">C</option><br>
<option value="a">A</option><br>


</select>
<?
echo "<select name= category >n<option selected>choose a category</option>";
$result7= mysql_query("select category from as group by category");
while($row7 = mysql_fetch_assoc($result7)) {
echo "<option value="$row7[category]">$row7[category]</option>";
}
echo "</select>";

?>
</td>
</tr>
<tr>
<td align="right"<?php if(!$fn) echo 'class="error"'; ?>>
First Name:
</td>
<td>
<input type="text" name="fname" size="30" value="<?= $fname ?>">
</td>
</tr>
<tr>
<td align="right"<?php if(!$ln) echo 'class="error"'; ?>>
Last Name:
</td>
<td>
<input type="text" name="lname" size="30" value="<?= $lname ?>">
</td>
</tr>
<tr>

<td align="right">
Address1:
</td>
<td>
<input type="text" name="address1" size="30" value="<?=$address1 ?>">
</td>
</tr>
<tr>
<td align="right">
Address2:
</td>
<td>
<input type="text" name="address2" size="30" value= "<?= $address2 ?>">
</td>
</tr>
<td align="right">
City:
</td>
<td>
<input type="text" name="city" size="30" value= "<?= $city ?>">
</td>
</tr>
<tr>
<td align="right">
State:
</td>
<td>
<br><select name="State" size=1 style= "background-color: #fff666; color:blue;">


<option value="Alabama"<Alabama></option><br>
<option value="Alaska">Alaska</option><br>
<option value="Arizona">Arizona</option><br>
<option value="Arkansas">Arkansas</option><br>
<option value="Chicago"<Chicago></option><br>
<option value="Cleveland">Cleveland</option><br>
<option value="Dallas">Dallas</option><br>
<option value="Denver">Denver</option><br>
<option value="Detroit"< Detroit></option><br>
<option value="Hartford">Hartford</option><br>
<option value="Houston">Houston</option><br>
<option value="Kansas">Kansas</option><br>
<option value="Iowa">Iowa</option><br>
</select></td>
<br><br>
</tr>
<td align="right">
Zip Code:
</td>
<td>
<input type="text" name="zipcode" size="10">
</td>
</tr>
<tr>
<td align="right">
Country:

</td>
<td>
<input type="text" name="country" size="30" value= "<?= $country?>">
</td>
</tr>
<td align="right">
Phone:
</td>
<td>
<input type="text" name="phone" size="30" value= "<?= $phone ?>">
</td>
<tr>
<td align="right"<?php if(!$em) echo 'class="error"'; ?>>
Email Address:
</td>
<td>
<input type="text" name="email" size="20" value="<?= $email ?>">
</td>
</tr>
<tr>
<td align="right"<?php if(!($ps && $ps2)) echo 'class="error"'; ?>>
Password:
</td>
<td>
<input type="password" name="password" size="10">
</td>
</tr>
<tr>
<td align="right"<?php if(!($ps && $ps2)) echo 'class="error"'; ?>>
Password Again:
</td>
<td>
<input type="password" NAME="password2" SIZE="10">
</td>
</tr>

<tr>
<td align="right">&nbsp;</td>
<td>
<input type="SUBMIT" name="submit" value="Submit">


</td>
</tr>
</table>
</form>

Reply With Quote
Old October 3rd, 2003, 06:51 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 10
RE: Clear Contents of registration form

it looks as if you are not setting the values of your variables to nothing when the form is submitted... It is kind of difficault to explain, but inside the if (isset ($_POST['submit'])) { conditional, you need to clear your variables after you insert the data into the db... follow the code flow and you should see what I mean...

Reply With Quote
Old October 10th, 2003, 07:54 AM
Zamolxe Zamolxe is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Craiova, Dolj, Romania
Posts: 4 Zamolxe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to Zamolxe
RE: Clear Contents of registration form

other options may be like this:
-user submit buttons and process them like this
<input name="users_login" type="submit" value="Login">
php Code:
Original - php Code
  1.  
  2. if($_POST['users_login']=="Login"){
  3. //INSERT and stuff
  4. }

-try to user separate file for procesing the request.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Clear Contents of registration form


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap