Jump to content

redirecting browser


brad12345

Recommended Posts

hi all i have a condition when a statement runs if it is tru i would like to redirect the browser back to another page

 

	if(empty($petName) || empty($petSpecies) || empty($petBreed)) {

//here is the code hopefully i can run to take them back to the page before....

}

 

thanks all

Link to comment
Share on other sites

Warning: Cannot modify header information - headers already sent by (output started at /home/it224/bradk/public_html/assignment1/newPatient.php:11) in

 

Error coming back? also a note it is not just a php script, the php script is inside the html, should this effect it?

Link to comment
Share on other sites

well then how am i supposed to run that code

 

maybe this will give better understanding

 

//Patient POST vaiables
$addPatient = $_POST['addPatient'];
$petName = $_POST['petName'];
$petSpecies = $_POST['petSpecies'];
$petBreed = $_POST['petBreed'];
$petAge = $_POST['petAge'];
$petWeight = $_POST['petWeight'];
$ownerID = $_POST['ownerID'];



echo("<font face='Arial'>");
$self = $_SERVER['PHP_SELF'];

//If a patient has been added from the form being filled out and 'addPatient' = true the preform below code	

if (isset($_POST['addPatient'])){
if(empty($petName) || empty($petSpecies) || empty($petBreed)) {
header("Location: http://kate/~bradk/newPatient.php");
}
//Adding patient into database
	$createQuery2 = "INSERT INTO tblPatientBK (petName, petSpecies, petBreed, petAge, petWeight, ownerID) VALUES ('$petName','$petSpecies','$petBreed','$petAge','$petWeight','$ownerID')";
	$result = mysql_query($createQuery2); //preforming mysql $createQuery2

	//displaying message to let user know the task has been carryed out and the patient has been added
	echo ("Thank you<p>Your new patient has been added successfully.<p>");

	echo("<a href='index.php'><font color='blue'>Return to home page</font></a>");

}		
else				  

 

also above all that is

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Veterinarian Patient Management Tool</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" /></head>

<body>
<div id="wrap">
    
    <div class="header"></div>
    
    
    
    
    
    
    <div class="pageTitle"><a href="index.php">Home</a> | <a href="newOwner.php">Add New Owner</a> | <a href="newPatient.php">Add New Patient</a> | <a href="deletePatient.php">Delete a Patient</a> | <a href="echoDB.php">Report</a> | <a href="search.php">Search</a></div>
    <div class="content">

Link to comment
Share on other sites

Warning: Cannot modify header information - headers already sent by (output started at /home/it224/bradk/public_html/assignment1/newPatient.php:11) in

 

Error coming back? also a note it is not just a php script, the php script is inside the html, should this effect it?

 

Yes--that error message is exactly what you get if you use the header cmd and have already sent anything to the browswer.

Link to comment
Share on other sites

put this code on top of the html

 

<?php

if (isset($_POST['addPatient'])){
if(empty($petName) || empty($petSpecies) || empty($petBreed)) {
header("Location: http://kate/~bradk/newPatient.php");
}
//Adding patient into database
	$createQuery2 = "INSERT INTO tblPatientBK (petName, petSpecies, petBreed, petAge, petWeight, ownerID) VALUES ('$petName','$petSpecies','$petBreed','$petAge','$petWeight','$ownerID')";
	$result = mysql_query($createQuery2); //preforming mysql $createQuery2

	//displaying message to let user know the task has been carryed out and the patient has been added
	echo ("Thank you<p>Your new patient has been added successfully.<p>");

	echo("<a href='index.php'><font color='blue'>Return to home page</font></a>");

}		
else	

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.