Issues: PHP Forms -Clearing
Posted on
16th Feb 2014 07:03 pm by
admin
I've tried looking online before actually asking for help, but I've been looking for about the past 3-5 hours and have found nothing that'll help me.
This is a project for school, and well I have to use Access as a database. I am using PHP for coding, and I'm fairly new to PHP. Now for the problem...
When I type in a Name in my Text Field all is good, I hit submit it works, if I hit reset it resets. My issue happens after I hit submit once the item is added, then if I refresh the page the item is added again, and it happens as many times as I hit refresh. I've tried numerous ways to make my text fields clear. I'm not coming up with anything. I started out having two files a PHP and HTML, I combined them hoping I could figure out a way to fix this, but to no avail.
If you look at my code you'll find that "odbc_exec($conn,$input);" is missing I took it out cause I have no idea where to put it, or what to do with it, or how to clear the fields upon having that executed.
If anyone could help me even the tiniest bit that'd be great
Code: <?php
$conn=odbc_connect('database','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$Name = $_POST["Name"];
$Submit = $_POST["Submit"];
$Reset = $_POST["Reset"];
$input="INSERT INTO Registry (FirstName) VALUES('$Name')";
$sql="SELECT * FROM Registry";
$rs=odbc_exec($conn,$sql);
?>
<html>
<body>
<form name="TestForm" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
Name: <input type="text" name="Name" maxlength=50/>
<p>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</form>
</body>
</html>
<?php
if (!$rs)
{exit("Error in SQL");}
echo "<table><tr>";
echo "<th>FirstName</th>";
echo "<th>LastName</th></tr>";
//Writes Table Values
while (odbc_fetch_row($rs))
{
$firstname=odbc_result($rs,"FirstName");
$lastname=odbc_result($rs,"LastName");
echo "<tr><td>$firstname</td>";
echo "<td>$lastname</td></tr>";
}
odbc_close($conn);
echo "</table>";
?>
No comments posted yet
Your Answer:
Login to answer
226
42
Other forums
query based on 2 conditions
I want to select if the doc_type is either s OR f but this doesn't work:
Code: [Select]$query
losing variables between php brackets
Hi
have got this code:
Code: $id=mysql_result($result,0,"itemid");
$title=mys
Serial number of exernal hard disk/Thumbdrive
Hi guys,
I am new tio java networking concepts.Please tel me how to get Serial
number of exernal
help me fix these syntax errors...
I keep getting multiple syntax errors on this script like this one:
Parse error: syntax error
Data storage spaces in varchar2
Trying to understand what's happening.
I am selecting a value from a table that is defined as c
UL and LI Add Form
The idea I want here is when the user click on a character name from the drop down select bar at the
Google Wave
So... has anyone used it yet? Is it any good?
http://wave.google.com/help/wave/about.html#vid
Load file in PHP
I have 2 files. The first is a PHP generated XML file that's dependent by 2 inputs. The second is a
Vertical Alligning - Not working in 1 cell?
<?php
echo "<table id="valign" width="60%" style=
Material Master Update through BAPI - Follow up material not updated
Hi Experts,
I am updating the material master through a custom transaction using the BAPI