Jump to content

Re-Directing Issues


BCAV_WEB

Recommended Posts

<?php

session_start( );

 

//Create arrays as session variables to hold form variables and errors

$_SESSION['track_errors'] = array();

$_SESSION['track_form_vars'] = array();

 

 

//Clear each of the form variables posted and assign to $_SESSION['formVars']

foreach($_POST as $varname => $value)

{

$_SESSION['track_form_vars'][$varname]  =  trim($value, 50);

}

 

  // Validate the First Name

if (empty($_SESSION['track_form_vars'] ["invoice_number"]))

// First name cannot be a null string

$_SESSION['track_errors']["invoice_number"] = "You must provide us your Invoice Number";

 

  // Validate the First Name

if (empty($_SESSION['track_form_vars'] ["track_order"]))

// First name cannot be a null string

$_SESSION['track_errors']["track_order"] = "You must provide us your Tracking Number";

 

 

if (count($_SESSION['track_errors']))

{

// There are errors.  Relocate back to the client form

header("Location: track_order.php");

exit;

}

else

{

 

}

?>

<?php include "sections/header.php";?>

<?php include "sections/left.php";?>

<!-- start content -->

<div id="content">

        <h2>Track Order</h2>

        <?php

include "connections/dbconnect.php";

$invoice_number =$_POST["invoice_number"];

  $track_order =$_POST["track_order"];

$query = "SELECT * FROM customers_orders WHERE invoice_no = '$invoice_number' AND  tracking_no = '$track_order'";

$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

// see if any rows were returned

if (mysql_num_rows($result) > 0)

{

$row = mysql_fetch_array($result);

print "

<table class='tracking_table'>

    <tr>

<td id='name'  colspan='11'>

 

Hello ".$row['fname']." ".$row['sname']."

<p></p>

</td>

</tr>

<tr>

<td colspan='11'>

Please find your personal tracking information below.

<p></p>

</td>

</tr>

<tr>

                                    <th class='text'>

Invoice Number

</th>

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['invoice_no']."

</td>

</tr>

                                    <tr>

                                    <th class='text'>

Date Ordered

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['date_of_order']."

</td>

</tr>

<tr>

                                        <th class='text'>

Status

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['status']."

</td>

</tr>

<tr>

                                        <th class='text'>

Date Expected

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['expected_delivery_date']."

</td>

                                    </tr>

                                    <tr>

<th class='text'>

Vehicle Make

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['vehicle_make']."

</td>

</tr>

<tr>

<th class='text'>

Vehicle Model

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['vehicle_ordered']."

</td>

</tr>

<tr>

<th class='text'>

Vehicle Colour

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['vehicle_colour']."

</td>

</tr>

<tr>

<th class='text'>

Vehicle Extras

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['vehicle_extras']."

</td>

</tr>

<tr>

<td colspan='11'>

Please use this to track your order for speed as it will be updated as and when it comes forward or moves out immediateley.

<p></p>

</td>

</tr>

 

</table>

  ";

}

else 

{

  header("Location: track_order.php");

exit;

}   

?>

 

           

        </div>

<!-- end content -->

<?php include "sections/right.php";?>

<?php include "sections/footer.php";?>

 

Any Idea why this isn't being re-directed to "track_order.php"?

 

Sorry if it has been mentioned previously and can I be directed to the correct information.

 

Link to comment
Share on other sites

All thats happening is the site is getting stuck on the "loginaction.php" all you see on the web browser in both firefox 3.6 and IE8 is a blank white screen. No idea why this is happening? Also I'm new to th forums any how do you edit the orginial post?

Link to comment
Share on other sites

If either of these included files

include "sections/header.php";

include "sections/left.php";

produce output to the browser, you need to move them inside the if(mysql_num_rows($result) > 0 ) { conditional for the header() redirect to work. You can't send anything at all to the browser before using header().

 

As far as editing your post, you only have 10 minutes to edit from the time you submit it.

Link to comment
Share on other sites

so something more like this?? The coding in the include header, left etc... is just normal HTML what would the best way around this be?

 

[

<?php

session_start( );

 

//Create arrays as session variables to hold form variables and errors

$_SESSION['track_errors'] = array();

$_SESSION['track_form_vars'] = array();

 

 

//Clear each of the form variables posted and assign to $_SESSION['formVars']

foreach($_POST as $varname => $value)

{

$_SESSION['track_form_vars'][$varname]  =  trim($value, 50);

}

 

  // Validate the First Name

if (empty($_SESSION['track_form_vars'] ["invoice_number"]))

// First name cannot be a null string

$_SESSION['track_errors']["invoice_number"] = "You must provide us your Invoice Number";

 

  // Validate the First Name

if (empty($_SESSION['track_form_vars'] ["track_order"]))

// First name cannot be a null string

$_SESSION['track_errors']["track_order"] = "You must provide us your Tracking Number";

 

 

if (count($_SESSION['track_errors']))

{

// There are errors.  Relocate back to the client form

header("Location: track_order.php");

exit;

}

else

{

 

}

?>

 

<!-- start content -->

 

        <?php

include "connections/dbconnect.php";

$invoice_number =$_POST["invoice_number"];

  $track_order =$_POST["track_order"];

$query = "SELECT * FROM customers_orders WHERE invoice_no = '$invoice_number' AND  tracking_no = '$track_order'";

$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

// see if any rows were returned

if (mysql_num_rows($result) > 0)

{

$row = mysql_fetch_array($result);

include "sections/header.php";

include "sections/left.php";

print "

<div id='content'>

        <h2>Track Order</h2>

<table class='tracking_table'>

    <tr>

<td id='name'  colspan='11'>

 

Hello ".$row['fname']." ".$row['sname']."

<p></p>

</td>

</tr>

<tr>

<td colspan='11'>

Please find your personal tracking information below.

<p></p>

</td>

</tr>

<tr>

                                    <th class='text'>

Invoice Number

</th>

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['invoice_no']."

</td>

</tr>

                                    <tr>

                                    <th class='text'>

Date Ordered

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['date_of_order']."

</td>

</tr>

<tr>

                                        <th class='text'>

Status

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['status']."

</td>

</tr>

<tr>

                                        <th class='text'>

Date Expected

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['expected_delivery_date']."

</td>

                                    </tr>

                                    <tr>

<th class='text'>

Vehicle Make

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['vehicle_make']."

</td>

</tr>

<tr>

<th class='text'>

Vehicle Model

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['vehicle_ordered']."

</td>

</tr>

<tr>

<th class='text'>

Vehicle Colour

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['vehicle_colour']."

</td>

</tr>

<tr>

<th class='text'>

Vehicle Extras

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['vehicle_extras']."

</td>

</tr>

<tr>

<td colspan='11'>

Please use this to track your order for speed as it will be updated as and when it comes forward or moves out immediateley.

<p></p>

</td>

</tr>

 

</table> 

</div>

  ";

include "sections/right.php";

include "sections/footer.php;"

}

else 

{

  header("Location: track_order.php");

  exit;

}   

?>

 

 

 

 

 

]

Link to comment
Share on other sites

so something more like this?? The coding in the include header, left etc... is just normal HTML what would the best way around this be?

 

<?php
session_start( );

//Create arrays as session variables to hold form variables and errors
 $_SESSION['track_errors'] = array();
 $_SESSION['track_form_vars'] = array();


//Clear each of the form variables posted and assign to $_SESSION['formVars'] 
 foreach($_POST as $varname => $value)
	{
		$_SESSION['track_form_vars'][$varname]  =  trim($value, 50);
	 }

  	// Validate the First Name
	if (empty($_SESSION['track_form_vars'] ["invoice_number"])) 
	// First name cannot be a null string
		$_SESSION['track_errors']["invoice_number"] = "You must provide us your Invoice Number";

  	// Validate the First Name
	if (empty($_SESSION['track_form_vars'] ["track_order"])) 
	// First name cannot be a null string
		$_SESSION['track_errors']["track_order"] = "You must provide us your Tracking Number";


	if (count($_SESSION['track_errors']))
			{
			 // There are errors.  Relocate back to the client form
			 header("Location: track_order.php");
			 exit;
			}
	else 
			{
   		
			}		 
?>

<!-- start content -->

        	<?php
			include "connections/dbconnect.php";
			$invoice_number =$_POST["invoice_number"]; 
   			$track_order =$_POST["track_order"];
			$query = "SELECT * FROM customers_orders WHERE invoice_no = '$invoice_number' AND  tracking_no = '$track_order'";
			$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
				// see if any rows were returned 
				if (mysql_num_rows($result) > 0) 
				 { 
				 	$row = mysql_fetch_array($result);
					include "sections/header.php";
					include "sections/left.php";
					print "
					<div id='content'>
        					<h2>Track Order</h2> 
							<table class='tracking_table'>
						    	<tr>
									<td id='name'  colspan='11'>

										Hello ".$row['fname']." ".$row['sname']."
										<p></p>
									</td>
								</tr>
								<tr>
									<td colspan='11'>
										Please find your personal tracking information below.
										<p></p>
									</td>
								</tr>	
								<tr>
                                    	<th class='text'>
										Invoice Number
									</th>
									<th class='dots'>
										:
									</th>
									<td  colspan='9'>
										".$row['invoice_no']."
									</td>
								</tr>						
                                    <tr>
                                    	<th class='text'>
										Date Ordered
									<th class='dots'>
										:
									</th>
									<td  colspan='9'>
										".$row['date_of_order']."
									</td>
								</tr>
								<tr>
                                        <th class='text'>
										Status
									<th class='dots'>
										:
									</th>
									<td  colspan='9'>
										".$row['status']."
									</td>
								</tr>
								<tr>
                                        <th class='text'>
										Date Expected
									<th class='dots'>
										:
									</th>
									<td  colspan='9'>
										".$row['expected_delivery_date']."
									</td>
                                    </tr>
                                    <tr>
									<th class='text'>
										Vehicle Make 
									<th class='dots'>
										:
									</th>
									<td  colspan='9'>
										".$row['vehicle_make']."
									</td>
								</tr>
								 <tr>
									<th class='text'>
										Vehicle Model 
									<th class='dots'>
										:
									</th>
									<td  colspan='9'>
										".$row['vehicle_ordered']."
									</td>
								</tr>
								 <tr>
									<th class='text'>
										Vehicle Colour
									<th class='dots'>
										:
									</th>
									<td  colspan='9'>
										".$row['vehicle_colour']."
									</td>
								</tr>
								 <tr>
									<th class='text'>
										Vehicle Extras 
									<th class='dots'>
										:
									</th>
									<td  colspan='9'>
										".$row['vehicle_extras']."
									</td>
								</tr>
								<tr>
									<td colspan='11'>
										Please use this to track your order for speed as it will be updated as and when it comes forward or moves out immediateley.
										<p></p>
									</td>
								</tr>

							</table>  
						</div>
						  ";
				include "sections/right.php";
				include "sections/footer.php;"
				 } 
				else  
				 {
				  header("Location: track_order.php");
			 	  exit;		
				 }    	
		?>





600px-Awesome_hurr_hurr.png&t=1

Link to comment
Share on other sites

Remove the HTML comment: <!-- start content --> , as it sends output to the browser.

There is a misplaced quote on this line: include "sections/footer.php;"

And there is an else { } statement that has nothing in the braces. It doesn't necessarily need to be removed, but it has no purpose and can be removed if you desire.

Link to comment
Share on other sites

This is the new amended coding, but unfortnately it still doesn't work  :-[ :-[ :-[ :-[ :-[ :-[ :-[

 

[

<?php

session_start( );

 

//Create arrays as session variables to hold form variables and errors

$_SESSION['track_errors] = array();

$_SESSION['track_form_vars'] = array();

 

 

//Clear each of the form variables posted and assign to $_SESSION['formVars']

foreach($_POST as $varname => $value)

{

$_SESSION['track_form_vars'][$varname]  =  trim($value, 50);

}

 

  // Validate the First Name

if (empty($_SESSION['track_form_vars'] ["invoice_number"]))

// First name cannot be a null string

$_SESSION['track_errors']["invoice_number"] = "You must provide us your Invoice Number";

 

  // Validate the First Name

if (empty($_SESSION['track_form_vars'] ["track_order"]))

// First name cannot be a null string

$_SESSION['track_errors']["track_order"] = "You must provide us your Tracking Number";

 

 

if (count($_SESSION['track_errors']))

{

// There are errors.  Relocate back to the client form

header("Location: track_order.php");

exit;

}

else

{

 

}

include "connections/dbconnect.php";

$invoice_number =$_POST["invoice_number"];

  $track_order =$_POST["track_order"];

$query = "SELECT * FROM customers_orders WHERE invoice_no = '$invoice_number' AND  tracking_no = '$track_order'";

$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());

// see if any rows were returned

if (mysql_num_rows($result) > 0)

{

$row = mysql_fetch_array($result);

include "sections/header.php";

include "sections/left.php";

print "

<div id='content'>

        <h2>Track Order</h2>

<table class='tracking_table'>

    <tr>

<td id='name'  colspan='11'>

 

Hello ".$row['fname']." ".$row['sname']."

<p></p>

</td>

</tr>

<tr>

<td colspan='11'>

Please find your personal tracking information below.

<p></p>

</td>

</tr>

<tr>

                                    <th class='text'>

Invoice Number

</th>

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['invoice_no']."

</td>

</tr>

                                    <tr>

                                    <th class='text'>

Date Ordered

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['date_of_order']."

</td>

</tr>

<tr>

                                        <th class='text'>

Status

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['status']."

</td>

</tr>

<tr>

                                        <th class='text'>

Date Expected

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['expected_delivery_date']."

</td>

                                    </tr>

                                    <tr>

<th class='text'>

Vehicle Make

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['vehicle_make']."

</td>

</tr>

<tr>

<th class='text'>

Vehicle Model

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['vehicle_ordered']."

</td>

</tr>

<tr>

<th class='text'>

Vehicle Colour

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['vehicle_colour']."

</td>

</tr>

<tr>

<th class='text'>

Vehicle Extras

<th class='dots'>

:

</th>

<td  colspan='9'>

".$row['vehicle_extras']."

</td>

</tr>

<tr>

<td colspan='11'>

Please use this to track your order for speed as it will be updated as and when it comes forward or moves out immediateley.

<p></p>

</td>

</tr>

 

</table> 

</div>

  ";

include "sections/right.php";

include "sections/footer.php;"

}

else 

{

  header("Location: track_order.php");

  exit;

}   

?>

]

 

 

Link to comment
Share on other sites

I have simplified the coding:

 

Can you see anything wrong with this at all?? This should be re-directing but it isn't I belive the issue is now with the dbconnect page (See second lots of coding) but I have no idea why it won't work  :shrug:

 

[<?php

    session_start( );

 

    //Create arrays as session variables to hold form variables and errors

    $_SESSION['track_errors'] = array();

    $_SESSION['track_form_vars'] = array();

   

                       

    //Clear each of the form variables posted and assign to $_SESSION['formVars']

    foreach($_POST as $varname => $value)

        {

            $_SESSION['track_form_vars'][$varname]  =  trim($value, 50);

        }

                                                                   

      // Validate the First Name

        if (empty($_SESSION['track_form_vars'] ["invoice_number"]))

        // First name cannot be a null string

            $_SESSION['track_errors']["invoice_number"] = "You must provide us your Invoice Number";

           

      // Validate the First Name

        if (empty($_SESSION['track_form_vars'] ["track_order"]))

        // First name cannot be a null string

            $_SESSION['track_errors']["track_order"] = "You must provide us your Tracking Number";

 

 

        if (count($_SESSION['track_errors']))

                {

                // There are errors.  Relocate back to the client form

                header("Location: track_order.php");

                exit;

                }

        else

                {

                    include "dbconnect.php";

                    // see if any rows were returned

                    header("Location: track_order.php");

                    exit;

                }       

?>

]

 

 

[

<?php

    $hostname = "sql5c30a.carrierzone.com";

    $username = "user";

    $password = "password";

    $databaseName = "main_bikescarsandvans_co_uk";

    $connection = mysql_connect($hostname, $username, $password);  // or die ("Unable to connect!")

    mysql_select_db($databaseName) or die ("Unable to select database!");     

?>

]

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.