Jump to content

PHP Mysql Headers Help


ATM

Recommended Posts

Anyway, I want to create a login system using PHP and Mysql, only problem is, it won't let me set the headers.

$mysql_connect = mysql_connect($mysql_servername,$mysql_username,$mysql_password );if (!$mysql_connect){die(header('Location: http://www.mydomain.com/'));}

In the code above it states that the line 33 has sent the header. Line 33 is the following line. $mysql_connect = mysql_connect($mysql_servername,$mysql_username,$mysql_password ); Anyway I can set the headers if the connection attemp fails?Thanks,

Link to comment
Share on other sites

<?php$username=$_POST["username"];$password=$_POST["password"];$mysql_username=$username;$mysql_password=$password;$mysql_servername="**********";$mysql_database="*******";$mysql_tablename_login="Login";$mysql_tablename_name="Name";$mysql_tablename_contact="Contact";$mysql_tablename_other="Other";$mysql_fieldname_user_id="User_ID";$mysql_fieldname_username="Username";$mysql_fieldname_password="Password";$mysql_fieldname_title="Title";$mysql_fieldname_first_name="First_Name";$mysql_fieldname_last_name="Last_Name";$mysql_fieldname_address_line_one="Address_Line_One";$mysql_fieldname_address_line_two="Address_Line_Two";$mysql_fieldname_city="City";$mysql_fieldname_county="County";$mysql_fieldname_country="Country";$mysql_fieldname_postcode="Postcode";$mysql_fieldname_telephone_number="Telephone_Number";$mysql_fieldname_mobile_number="Mobile_Number";$mysql_fieldname_email_address="E-mail_Address";$mysql_fieldname_fax="Fax";$mysql_fieldname_primary_domain="Primary_Domain";$mysql_fieldname_ip_address="IP_Address";$mysql_fieldname_xml_reference="XML_Reference";$mysql_fieldname_xml_version="XML_Version";$mysql_fieldname_date_created="Date_Created";$mysql_connect=mysql_connect($mysql_servername,$mysql_username,$mysql_password);if (!$mysql_connect){die(header('Location: [url=http://www.mysite.com/'));]http://www.mysite.com/'));[/url]}?>

don't see anything, the code isn't finished yet. The above is what I have done so far.

Link to comment
Share on other sites

Is that a blank line before the opening php tag? or just the way the code is displayed inside the bbcode code tags? If there is a blank line in your actual code, that's the problem. The blank line should be removed.

Link to comment
Share on other sites

it's just how the code is shown, In the real code there is no space.I think it's that if the connection fails then it will write an error, and the error is the header which is stoping me from sending one, I think? is there anyway to stop this?thanks,

Link to comment
Share on other sites

So, just to clarify, you have this:

if (!$mysql_connect){  header('Location: http://www.mydomain.com/');    die();}

And it is not working? If that is not working, then you have some output being sent to the browser before the header. If that is the case, then the error message will tell you where the output starts. If the connection attempt is generating a warning or error, then you can use the @ operator to suppress the message.$mysql_connect = @mysql_connect(...);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...