Help : how can I open a new page in php
Moderator: General Moderators
Help : how can I open a new page in php
Hello,
I m facing a problem. I m trying to get information from my sql database, and i want, if possible, to open a new page when an error occurs.
Any idea on how can i open a new page in php ?
Thx in advance
[/syntax]
I m facing a problem. I m trying to get information from my sql database, and i want, if possible, to open a new page when an error occurs.
Any idea on how can i open a new page in php ?
Thx in advance
[/syntax]
Last edited by rana on Tue May 01, 2007 4:39 pm, edited 1 time in total.
Hello Rana, welcome to the forum. Please read the forum rules.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
hey,
(in fact i m a girl
)
Well to be more explicit, here 's my problem :
I have 2 pages :
page one is a form and when the user click on submit, it opens an php page that should insert into my sql database information like this
instead of having my message "error insert ..." i wanna open a new page with a specific message
thx
(in fact i m a girl
Well to be more explicit, here 's my problem :
I have 2 pages :
page one is a form and when the user click on submit, it opens an php page that should insert into my sql database information like this
Code: Select all
<?php
function insertResa ()
{
$FirstName= $_POST['Itm_8_00_3'];
$LastName= $_POST['Itm_8_00_5'];
$Nationality = $_POST['Itm_8_00_6'];
$Email= $_POST['Itm_8_00_7'];
$PhoneNumber=$_POST['Itm_8_00_8'];
$req="insert into client (FirstName,LastName, Nationality, Email, PhoneNumber) values ('$FirstName','$LastName', '$Nationality', '$Email', '$PhoneNumber')";
include 'Connexion.php';
$creer = mysql_query($req) or die ('Erreur d insertion'.mysql_error());
if ($creer)
{
echo "ok";
}
else
{
echo "Error inserting client";
}
?>thx
Code: Select all
header("Location: http://path/to/error_page.html")Welcome by the way
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Re: Help : how can I open a new page in php
rana wrote:Hello,
I m facing a problem. I m trying to get information from my sql database, and i want, if possible, to open a new page when an error occurs.
Any idea on how can i open a new page in php ?
Thx in advance
[/syntax]
I think you could use this:
Code: Select all
if($yourError == true){
echo '<meta http-equiv="REFRESH" content="0;url=errorPage.php">';
}- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Everah | Edited this post to reflect how we would like it to look.
[s]thx[/s] Thanks for [s]ur[/s] your tips but [s]i[/s] I couldn t make them work.
In fact [s]ur[/s] you're right, [s]i[/s] I don t want to open a new page but redirect it to my new page error.html
[s]thx[/s] Thanks for [s]ur[/s] your help
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.
Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.
[s]thx[/s] Thanks for [s]ur[/s] your tips but [s]i[/s] I couldn t make them work.
In fact [s]ur[/s] you're right, [s]i[/s] I don t want to open a new page but redirect it to my new page error.html
[s]thx[/s] Thanks for [s]ur[/s] your help
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Redirects can be handled using header(). Just make sure you use a full URI.
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
Yeah, last I checked, Rana IS a girl's name.Rana wrote:(in fact i m a girl)
You have to use a full URI? Why? What's wrong with relative redirection?Everah wrote:Redirects can be handled using header(). Just make sure you use a full URI.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Click on the link to the manual page for header() and you'll find this a few scrolls down:
Note: HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme, hostname and absolute path, but some clients accept relative URIs. You can usually use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF'] and dirname() to make an absolute URI from a relative one yourself:
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Have a look at the response headers one of these days. If you see:
Then you may want to look at moving to the HTTP 1.1 spec which is full URI.
Code: Select all
HTTP/1.1 200 OK