Ok this is the script that handles the form submission and input's it to the SQL database. It works 100%. -
<?php
-
$con = mysql_connect("*****","*****","*****");
-
if (!$con)
-
{
-
die('Could not connect: ' . mysql_error());
-
}
-
mysql_select_db("ccsdesig_first", $con);
-
$sql="INSERT INTO ***** (Name,Surname,Number,Email,MovingFrom,MovingTo,Date)
-
VALUES ('$_POST[Name]','$_POST[Surname]','$_POST[Number]','$_POST[email]','$_POST[MovingFrom]','$_POST[MovingTo]','$_POST[Date]')";
-
-
$sql="INSERT INTO destination (CurrentPremises,CurrentFloor,DestinationPremises,DestinationFloor,WrapEverything,Unpack,Hangerpack,SendMaterials,InsureEverything)
-
VALUES ('$_POST[CurrentPremises]','$_POST[CurrentFloor]','$_POST[DestinationPremises]','$_POST[CurrentFloor]','$_POST[WrapEverything]','$_POST[Unpack]','$_POST[Hangerpack]','$_POST[SendMaterials]','$_POST[InsureEverything]')";
-
-
if (!mysql_query($sql,$con))
-
{
-
die('Error: ' . mysql_error());
-
}
-
mysql_close($con)
-
echo "Done";
-
?>
-
What I would now like the script to do is to send the user to another page - what do I use to automatically redirect?
I've tried: -
header("Location:http://www.xxxxxxx.com/viewguestbook2.php");
-
and -
<META HTTP-EQUIV="refresh" content="0;URL=index.php">
-
And neither works - could someone point me in the right direction please?
My thanks in anticipation
16 6435
you can use a JS to redirect user
Regards
Atli 5,058
Expert 4TB
Hey.
What happened when you tried the header() function? It should have worked. (Try turning on the error messages to see what really happened.)
You can do three things to redirect a user: - Send a Location header, using the header function. - This is the preferred method, as it is the "shortest" way to send the browser the request to relocate.
- Add a <meta> "refresh" header. - This is a close second, only because it requires the browser to parse the HTML before actually getting the request.
- Send a JavaScript "location.href" value. - This should be avoided, because JavaScript can not be counted on in all cases. Users can turn off JavaScript, and some browser (and I use that term loosely) don't support it.
Hi,
I get the following error:
Parse error: syntax error, unexpected T_STRING in /home/****/public_html/insert.php on line 21
When using the following: -
<?php
-
error_reporting(E_ALL);
-
ini_set('display_errors', true);
-
$con = mysql_connect("localhost","*****","*****");
-
if (!$con)
-
{
-
die('Could not connect: ' . mysql_error());
-
}
-
mysql_select_db("*****", $con);
-
$sql="INSERT INTO contactdetails (Name,Surname,Number,Email,MovingFrom,MovingTo,Date)
-
VALUES ('$_POST[Name]','$_POST[Surname]','$_POST[Number]','$_POST[email]','$_POST[MovingFrom]','$_POST[MovingTo]','$_POST[Date]')";
-
-
$sql="INSERT INTO destination (CurrentPremises,CurrentFloor,DestinationPremises,DestinationFloor,WrapEverything,Unpack,Hangerpack,SendMaterials,InsureEverything)
-
VALUES ('$_POST[CurrentPremises]','$_POST[CurrentFloor]','$_POST[DestinationPremises]','$_POST[CurrentFloor]','$_POST[WrapEverything]','$_POST[Unpack]','$_POST[Hangerpack]','$_POST[SendMaterials]','$_POST[InsureEverything]')";
-
-
if (!mysql_query($sql,$con))
-
{
-
die('Error: ' . mysql_error());
-
}
-
mysql_close($con)
-
header("Location: http://www.xxx.com/email.php");
-
exit;
-
?>
-
Atli 5,058
Expert 4TB
You are missing the semi-colon (;) from line #20. All lines must end in a semi-colon.
@Atli
Warning: Cannot modify header information - headers already sent by (output started at /home/****/public_html/insert.php:1) in /home/****/public_html/insert.php on line 21
you cannot have any echo statements or none php codes before the header
ie. you cannot send any output to the browser before header()
make sure that (even a white space could case an error)
Regards
Thanks for your reply.
I checked through the code and dont think anything is posting to the browser at all. Perhaps I have missed something though? -
<?php
-
error_reporting(E_ALL);
-
ini_set('display_errors', true);
-
$con = mysql_connect("*","*","*");
-
if (!$con)
-
{
-
die('Could not connect: ' . mysql_error());
-
}
-
mysql_select_db("*", $con);
-
$sql="INSERT INTO contactdetails (Name,Surname,Number,Email,MovingFrom,MovingTo,Date)
-
VALUES ('$_POST[Name]','$_POST[Surname]','$_POST[Number]','$_POST[email]','$_POST[MovingFrom]','$_POST[MovingTo]','$_POST[Date]')";
-
$sql="INSERT INTO destination (CurrentPremises,CurrentFloor,DestinationPremises,DestinationFloor,WrapEverything,Unpack,Hangerpack,SendMaterials,InsureEverything)
-
VALUES ('$_POST[CurrentPremises]','$_POST[CurrentFloor]','$_POST[DestinationPremises]','$_POST[CurrentFloor]','$_POST[WrapEverything]','$_POST[Unpack]','$_POST[Hangerpack]','$_POST[SendMaterials]','$_POST[InsureEverything]')";
-
if (!mysql_query($sql,$con))
-
{
-
die('Error: ' . mysql_error());
-
}
-
mysql_close($con);
-
header("Location: http://www.*.co.za/email.php");
-
exit;
-
?>
-
Warning: Cannot modify header information - headers already sent by (output started at /home/*/public_html/insert.php:1) in /home/*/public_html/insert.php on line 19
Atli 5,058
Expert 4TB
If you are getting that error, something is being printed before the header() call.
This is usually caused by white-spaces or other junk before the <?php block, BOM chars in Unicode documents or random echos in the code. - Check the source in the browser. That should include the junk chars that are causing this. (Post it here if you want us to take a look at it.)
You can also read this article for more details about this error, and how to fix it.
I read the article - thank you.
As far as I can see I have removed all the white spaces. Below is the code - Pls can you check where I have gone wrong: -
<?php
-
$con = mysql_connect("*","*","*");
-
if (!$con)
-
{
-
die('Could not connect: ' . mysql_error());
-
}
-
mysql_select_db("*", $con);
-
$sql="INSERT INTO contactdetails (Name,Surname,Number,Email,MovingFrom,MovingTo,Date)
-
VALUES ('$_POST[Name]','$_POST[Surname]','$_POST[Number]','$_POST[email]','$_POST[MovingFrom]','$_POST[MovingTo]','$_POST[Date]')";
-
$sql="INSERT INTO destination (CurrentPremises,CurrentFloor,DestinationPremises,DestinationFloor,WrapEverything,Unpack,Hangerpack,SendMaterials,InsureEverything)
-
VALUES ('$_POST[CurrentPremises]','$_POST[CurrentFloor]','$_POST[DestinationPremises]','$_POST[CurrentFloor]','$_POST[WrapEverything]','$_POST[Unpack]','$_POST[Hangerpack]','$_POST[SendMaterials]','$_POST[InsureEverything]')";
-
if (!mysql_query($sql,$con))
-
{
-
die('Error: ' . mysql_error());
-
}
-
mysql_close($con);
-
header("Location: http://www.*.co.za/email.php");
-
exit;
-
?>
-
Atli 5,058
Expert 4TB
We aren't talking about white-spaces inside the <?php .. ?> blocks, but outside them. White-spaces inside them don't matter. - <?php
-
// There are three white-spaces before the <?php tag
-
// above this comment. This will cause the error.
-
-
$variable = '
-
something
-
something else.';
-
// The white-spaces in the above variable,
-
// or the string, have no effect.
-
?>
Did you check out the source of the page in your browser? How did it look like?
Understood and as you can see there are no white spaces in the code I posted. I dont know how to view a PHP files source without it actually processing the script first. Once it processes the script the source is the following: -
<br />
-
<b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/ccsdesig/public_html/insert.php:1) in <b>/home/ccsdesig/public_html/insert.php</b> on line <b>17</b><br />
-
If I open the PHP with notepad the source looks exactly the same as it does in expression web and as I posted above.
Atli 5,058
Expert 4TB
Ok. The error still points to line #1 of the file, saying the output is starting there.
I would guess that your IDE is adding a BOM to your document; a Unicode special character that is meant to tell how the Unicode chars in the document are structured.
To check and fix that, you need an editor that can re-encode the file. I've used Notepad++ for that in the past. It's a very small and simple editor. A sort of advanced version of Notepad.
You can open your document in there, select "Encoding > Encode in UTF-8 without BOM", and then save the file.
That might fix the error.
The encoding resolved it!
Thank you!
Atli 5,058
Expert 4TB
No problem. Glad it worked out :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sentinel |
last post by:
here is the entire thread
From: "Kimmo Laine" <eternal.erectionN0.5P@Mgmail.com>
Subject: Re: script in body
Date: Mon, 20 Jun 2005 17:46:28 +0300
Message-ID:...
|
by: T Conti |
last post by:
Howdy:
I have converted a huge ASP page over to .Net (C#). The old page has
been will be removed from our site, but I need to have a dummy page
there that will redirect the user to the new site...
|
by: Noozer |
last post by:
Is it possible to redirect a user to another web page using ASP code located
in page body?
I have some ASP code that runs after generating some output to the browser.
It checks for a condition...
|
by: SiteTamer |
last post by:
I have a script that redirects to a file for downloading. Everything works
fine EXCEPT:
if the target of the redirect is type video/mpeg (extension .mpeg or .mpg),
instead of prompting for...
|
by: Drebin |
last post by:
I posted this over at the ASP.NET group, but you guys are pretty sharp - is
this an obvious answer for anyone?? I'm really jammed up!!
---------------------------------------
I am retrofitting...
|
by: Drebin |
last post by:
I am retrofitting a central login application and want to be able to read
the Request.ServerVariables so that when they have logged
on, I can send them back to wherever they were trying to go..
...
|
by: Josselin |
last post by:
I have a page 'pni.php' to which paypal is redirecting after payment
thsi page contains a db update script, no problem it's running well
but once this script is executed (transparently for the...
|
by: Dave |
last post by:
Is there a way to do a Response.Redirect and do a popup on the redirect?
|
by: venner |
last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET
2.0. The website makes use of a central authentication service (CAS)
provided at the university I work for. Each page checks...
|
by: gnawz |
last post by:
Hi guys,
I have a couple of php files that perform various tasks.
I will use fields in my system and provide code as well
I need help as follows:
My database contains the fields Category...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |