Location header why is it not going to the link

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Location header why is it not going to the link

Post by mohson »

Can anyone see why once my insert has been performed why the page doesnt load the URL at the bottom instead it loads the same process page. Once I click enter it should load the URL at the bottom this was working fine before.

Code: Select all

<?php
/* Connecting, selecting database */
$link = mysql_connect("xxxx", "xxxx", "xxxx")
   or die("Could not connect : " . mysql_error());

mysql_select_db("contact_management_system",$link) or die("Could not select database");
 $sql = "INSERT INTO studentwebsites (name, organisation, website) VALUES ('$name','$organisation','$website')";
 $result = mysql_query($sql,$link) or die ( mysql_error($link));;
 header ("location:http://www.soi.city.ac.uk/organisation/pl/Manage_Websites/addnewwebsite.html");
 ?>
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

When I send headers, it's of this format:

Code: Select all

header(&quote;Location: http://mywebsite.etc&quote;);
I imagine syntax, capitalization and whitespace are very important
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Just to clarify... Location not location.

Also I always tend to put a php command "exit;" on the line after the header. Makes it clear to any reader that the code should stop there.
Post Reply