Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 21-01-2009
Member
 
Join Date: Dec 2008
Posts: 13
Reloading same page using PHP

Hi,

I am new to php. I have a page with a form, and the code to process the form answers, I want the same page/form to just reload when the user presses submit but i am not able to do it.

anyone have any tips for me on a good way to do this?

Any help appreciated

Thanks.
Reply With Quote
  #2  
Old 21-01-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: Reloading same page using PHP

I think you should just set the form's action to the current page.

Code:
<form action="<?php echo $PHP_SELF; ?>" method="post">
Or

Code:
<form action="thispage.php" method="post">
Reply With Quote
  #3  
Old 21-01-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Reloading same page using PHP

Hope, this code will help you

Code:
<?php


$page = $_SERVER['PHP_SELF'];

 
$sec = "10";

 
header("Refresh: $sec; url=$page");
 

echo "Watch the page reload itself!";
 

?>
Reply With Quote
  #4  
Old 21-01-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Reloading same page using PHP

I have used the same feature for my application, so giving you a code of that particular page.
This code worked properly for me. so try by using this one.

Code:
<HTML>
<HEAD>
<LINK REL=stylesheet HREF="../tape.css" TYPE="text/css">
</HEAD>
<BODY>

<?php
if ($submit)
{
// process form
$companyname=ucfirst($companyname);
$address1=ucfirst($address1);
$address2=ucfirst($address2);
$address3=ucfirst($address3);
$address4=ucfirst($address4);
$ref=ucfirst($ref);
$names=ucfirst($names);
$db = mysql_connect("server", "user") or die("Could not connect : "
.. mysql_error());
mysql_select_db("addresses",$db);
$sql = "INSERT INTO coa (CompanyName, Address1, Address2, Address3,
Address4, Ref, Names) VALUES
('$companyname','$address1','$address2','$address3 ','$address4','$ref','$nam
es')";
$result = mysql_query($sql);
echo "Thank you! Information entered.\n";
//clear field contents
$companyname="";
$address1="";
$address2="";
$address3="";
$address4="";
$ref="";
$names="";
// Currently I have to click a url to reload page
echo "<A HREF=\"../coa.php\">Add more records</A>";

}

// display form
?>
<H1>Enter new details</H1>
<BR>
<FORM method="post" action="<?php echo $PHP_SELF?>">
<TABLE width="100%" border="0">
<TR>
<TD width="15%">Company Name:</TD><TD><INPUT type="Text"
name="companyname"><BR></TD>
</TR>
<TD width="15%">Address:</TD><TD><INPUT type="Text"
name="address1"><BR></TD>
</TR>
<TD width="15%">Address:</TD><TD><INPUT type="Text"
name="address2"><BR></TD>
</TR>
<TD width="15%">Address:</TD><TD><INPUT type="Text"
name="address3"><BR></TD>
</TR>
<TD width="15%">Address:</TD><TD><INPUT type="Text"
name="address4"><BR></TD>
</TR>
<TD width="15%">Reference No:</TD><TD><INPUT type="Text"
name="ref"><BR></TD>
</TR>
<TD width="15%">Names:</TD><TD><INPUT type="Text"
name="names"><BR></TD>
</TABLE>
<BR>
<BR>
<TABLE width="100%" border="0">
<TR>
<TD width="30%"><INPUT type="Submit" name="submit" value="Enter
Information"></TD>
<TD width="50%"></TD>
</TR>
</TABLE>
<HR>
</FORM>

</BODY>
</HTML>
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Reloading same page using PHP"
Thread Thread Starter Forum Replies Last Post
AOL keeps reloading wordswort Technology & Internet 3 04-11-2011 01:12 AM
Hate weapon reloading in Serious Sam 3 Yistor Video Games 5 09-08-2011 07:46 AM
Reloading Office Ultimate 2007 Scottaw67 Windows Software 1 11-05-2011 11:33 AM
Reloading Animations in Homefront Zathara Video Games 5 25-03-2011 10:56 PM
Reloading issue with Norton 360 Tanmaya84 Networking & Security 4 17-09-2010 10:38 PM


All times are GMT +5.5. The time now is 12:34 AM.