include "include/connection.php";
$date= date("Y-m-d H:i:s");
$profile_comment="INSERT INTO `infotown_test`.`profile_comments` (`id`, `user_id`, `name`, `email`, `comments`, `date_and_time`) VALUES (NULL, '".$_REQUEST['user_id']."', '".$_REQUEST['name']."', '".$_REQUEST['email']."', '".$_REQUEST['comment']."', '".$date."')";
mysql_query($profile_comment);
header("location:company-profile.php?id=2");(why it's not working?)
Asked
Active
Viewed 206 times
1

Syed mohamed aladeen
- 6,507
- 4
- 32
- 59

nitul
- 9
- 6
-
do you have any html content or echo before that header? – Syed mohamed aladeen Mar 11 '16 at 11:31
-
use $id = mysql_insert_id(); I think it is not working because of id – codeGig Mar 11 '16 at 11:31
-
2Check query error before header. You should ON your error reporting in development mode. – Ravi Hirani Mar 11 '16 at 11:32
-
1Try `exit()` after `header()` function. – Sanjay Chaudhari Mar 11 '16 at 11:32
-
use ob_start(); at the start of the script. – Rahul Singh Mar 11 '16 at 11:34
-
1**Danger**: You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). You are **vulnerable to [SQL injection attacks](http://bobby-tables.com/)** that a modern API would make it easier to [defend](http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php) yourself from. – Quentin Mar 11 '16 at 11:34
-
@syed mohamed: no html content or echo.... – nitul Mar 11 '16 at 11:35
-
@Jitendra: I tried without id like index.php – nitul Mar 11 '16 at 11:37
-
Guys I already tried your all suggestions....... – nitul Mar 11 '16 at 11:40
-
try --> mysql_query($profile_comment) or die('Error'); and see if you get any error – Dimag Kharab Mar 11 '16 at 11:40
-
@n01ze: I used no error showing. – nitul Mar 11 '16 at 11:43
-
@nitul ok , the record is getting inserted huh ?! – Dimag Kharab Mar 11 '16 at 11:44
-
@n01ze: yes record inserted into datbase – nitul Mar 11 '16 at 11:46
-
Possible duplicate of [PHP header redirect not working](http://stackoverflow.com/questions/1242033/php-header-redirect-not-working) – Syed mohamed aladeen Mar 11 '16 at 12:04
1 Answers
0
Make the "location" Capital to "Location",
header("Location:company-profile.php?id=2");

Dimag Kharab
- 4,439
- 1
- 24
- 45