Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control display of webpage

Status
Not open for further replies.

jbeetz1

Programmer
Nov 28, 2000
60
US
Hi

I have a webpage that upon clicking the "Submit" button executes the url designated by the action parameter on the <form line. The only action the called page does is to commit the information from the calling url to a MYSQL database. If the commit is successful I would like to just close this webpage, without displaying it and return to the calling webpage.

Is this possible?

Thanks
Jerry
 
You can issue a header("location:callingpage.php"); after all the processing is done and assuming you don't output anything to screen.

Or you can just have all your processing code be in the original calling page, and on submit just process the form, and redisplay it.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Phil

I had the processing code in the calling page originally but I was told I had to use AJAX to have it work correctly and I don't know AJAX.

Thanks
Jerry
 
Whoever said that clearly had no idea what he was talking about.

Example:

Code:
<html>
<head><title>Form</title></head>
<body>
<form action="myform.php" method=POST>
<input type="text" name="name" value="">
...

<input type="submit" name="process" value="Process Form">
</form>

<?PHP
[green]\\check if the form has been submitted, usually by checking if the submit button's alue is present in the POST array[/green]
if(isset($_POST['process'])){

[green]\\Process code here
...

[green]\\If processing successful, maybe echo out a message:[/green]
echo "Your input has been successfully processed";
}

?>

</body>
</html>

[/code]


Once the form is submitted, the page will reload run the PHP code, and unless there's an error show the now empty form with whatever message you decided to add at the end if you so choose.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Phil

I appreciate all your help but I cannot get it to work (execute the process code). Here is a partial of my page script (mamange_league.php).

<html>
<head>

include 'dbconn_fantasy.php';
$league_sql = mysql_query("SELECT league_name FROM leaguemanager WHERE league_id = '$league_id'");
$rs1 = mysql_fetch_array($league_sql);

?>

<SCRIPT LANGUAGE="JavaScript" SRC="scripts/FSdateSelect.js"></SCRIPT>

<title>League Manager</title>

</head>
<body bgcolor="#a80000" >

<form method=post action="manage_league.php" name="DateFormStart">

Draft cutoff (weekly): <select size="1" name="day"><option value="Sunday"
selected>Sunday</option> <option value="Monday">Monday</option> <option
value=Tuesday>Tuesday</option> <option
value=Wednesday>Wednesday</option> <option
value=Thursday>Thursday</option> <option value="Friday">Friday</option>
<option value="Saturday">Saturday</option>
...

<input type=submit name="Submit" value=Submit></center>
</form>

<?
if (isset($_POST['Submit']))
{
$sql_delete = "delete from league_options where league_id = '$league_id'";
mysql_query($sql_delete);
echo "DELETE Successful";
}
?>
</body>
</html>
 
What should it do ?
What is is actualy doing ? i.e. does the data base bit work ?
where does $league_id come from ?
 
There's nothing that looks wrong in your code.

Perhaps its the fact that the deletion is occurring after you display the DB data so you don't get the updated display until after you refresh the page.

If that's the case, I would move the deletion code to before the display, so the newly displayed data is the up to date one after the deletion has taken place.


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top