php to html page redirection after performing a db insert query – PHP

  php

Q(Question):

My php script performs a insert query ,
Then i want it to go to another html page.
header(‘Location : <url>’) not working.
I an working on wamp server.

A(Answer):

The problem is lines 24 thru 30. Delete them and all will be well. 😉

If you want serious answers, you’ll need to post your code and explain what you mean by "not working". Do you receive any error message? Does it redirect to the somewhere else? Does it cause your computer to catch on fire?

A(Answer):

My code:

<?php
$con = new mysqli("localhost:3306","root","","parking");
if($con->connect_error){
die("connectionn failed".$con->connect_error);
}
$url='localhost/4 user hame page.html';
$nam=$_REQUEST["name"];
$ag=$_REQUEST["age"];
$pho=$_REQUEST["phonenumber"];
$mai=$_REQUEST["mailid"];
$uname=$_REQUEST["Username"];
$pwd=$_REQUEST["password"];
$con->query("INSERT INTO `user` (`name`, `age`, `gender`, `phone`, `mailid`, `uname`, `pwd`) VALUES ('$nam', '$ag', 'f', '$pho', '$mai', '$uname', '$pwd')");
header("Loaction: localhost/4 user home page.html/");
?>

not working in the sense nothing happens, i.e no redirection or error.

A(Answer):

Do you have error reporting enabled?

Do you get a blank page, or something else?

Are you using the full URL in the redirect, or a relative path? If it’s a relative path, you should change it to the full URL.

A(Answer):

blank page only.
it’s the full url

A(Answer):

Please use code tags when posting code or formatted data.

Does it insert the data?

Your problem is line 19. You spelled Location wrong.

Also, your other problem is line 19. Unless the client is viewing this page from the same computer that the web server is on, the client computer can’t resolve the localhost reference.

A(Answer):

Thanks got it , after the spelling correction .

LEAVE A COMMENT