BCAV_WEB Posted September 24, 2010 Share Posted September 24, 2010 Hello, I'm having some major major issues, with a web hosting / PHP / MySQL database issue and if anyone can help that would be amazing! Okay first I have a MySQL database setup, with a table called "staff", within that there is a "username" and "password" field pretty self explanatory. I have a login in page (login.php) see first set of coding and a loginaction (loginaction.php) and what is suppose to happen is the loginaction checks the posted data against the database and if correct relocate to another page. I have had this coding and much more complex coding working on various other servers, but this is the first time I've ever dealt with BT Business webhosting, which is pretty useless right now and poor help to date from technicians who say it is a purely a coding issue. From what I have established I believe that the issue is occuring because BT don't have the apache server setup correctly for what I'm trying to do or that the browser is seeing the "$result" on "loginaction.php" and data, resulting in a white page of certain doom! Please help!! login.php [<?php include "sections/phparea.php";?> <?php include "sections/header.php";?> <?php include "sections/left.php";?> <!-- start content --> <div id=content"> <?php // Include the formatted error message if (isset($_SESSION['message])) echo "<h4>".$_SESSION['message']."</h4>"; // Generate the login <form> layout ?> <form action="loginaction.php" method="post" enctype="multipart/form-data"> <table class="tablelogin" > <tr> <td> <label for="email">E-mail Address</label> </td> <td> <input type="text" name="email" id="email" /> </td> </tr> <tr> <td> <label for="password">Password</label> </td> <td> <input type="password" name="password" id="password" /> </td> </tr> <tr> <td> </td> <td> <a href="../ambustar/accountrecovery.php">Forgotten Password?</a> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> <input type="hidden" name="count" id="count" value="1" /> <input type="reset" name="reset" id="reset" value="Clear" /> <input type="submit" name="submit" id="submit" value="Log in" /> </td> </tr> </table> </form> </div> <!-- end content --> <?php include "sections/right.php";?> <?php include "sections/footer.php";?> ] loginaction.php [<?php session_start(); include "dbconnect.php"; $email =$_POST["email"]; $password =$_POST["password"]; $query = "SELECT * FROM staff WHERE username = '$email' AND password = '$password'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($result) > 0) { header("Location: test.php"); } else { header("Location: login.php"); } ?> ] dbconnect.php [<?php $hostname = "sql5c30a.carrierzone.com"; $username = "user"; $password = "password"; $databaseName = "main_bikescarsandvans_co_uk"; $connection = mysql_connect($hostname, $username, $password); // or die ("Unable to connect!") mysql_select_db($databaseName) or die ("Unable to select database!"); ?> ] Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 24, 2010 Share Posted September 24, 2010 Add the following two lines of code between the <?php tag and the session_start() statement in loginaction.php - ini_set("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment Share on other sites More sharing options...
BCAV_WEB Posted September 24, 2010 Author Share Posted September 24, 2010 This is the error I got Warning: Cannot modify header information - headers already sent by (output started at /services3/webpages/b/i/bikescarsandvans.co.uk/public/dbconnect.php:10) in /services3/webpages/b/i/bikescarsandvans.co.uk/public/loginaction.php on line 14 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 24, 2010 Share Posted September 24, 2010 Based on where the output is being reported at by the error message and that there are not 10 lines of code in dbconnect.php, you likely have characters after the closing ?> tag in the file and they should be removed as they are content that is being output to the browser. And since this is not a mysql problem, moving thread to the php help forum section... Quote Link to comment Share on other sites More sharing options...
BCAV_WEB Posted September 24, 2010 Author Share Posted September 24, 2010 Resolved, as soon as I got this output I figured out what was happening via a bit ot trial and error. On the "dbconnect.php" I had both <?php and ?> when removing both I was unable to connect to the database at all, but when removing the end ?> on the "dbconnect.php" file the coding worked fine and that has allowed me to implement the more complex coding. Thank you for all your help! That little bit of coding you gave me saved me from more stress, as I have been looking / dealing with this error for a couple of days now. I'm in a good mood now, with 15 minutes until my weekend offically starts!! :D :D :D Quote Link to comment Share on other sites More sharing options...
chintansshah Posted September 24, 2010 Share Posted September 24, 2010 Please write exit; after header function Use ob_start() on top of the page and ob_end on end of the page. Quote Link to comment Share on other sites More sharing options...
BCAV_WEB Posted September 24, 2010 Author Share Posted September 24, 2010 what do they do? Quote Link to comment Share on other sites More sharing options...
chintansshah Posted September 24, 2010 Share Posted September 24, 2010 These function used for output buffering. sometime you get an error of header already sending, you may avoid such error using these. http://php.net/manual/en/function.ob-start.php Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted September 24, 2010 Share Posted September 24, 2010 Using output buffering, in most cases is just a lazy way of masking a problem instead of actually fixing it. Quote Link to comment Share on other sites More sharing options...
BCAV_WEB Posted September 24, 2010 Author Share Posted September 24, 2010 cheers! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted September 24, 2010 Share Posted September 24, 2010 Using output buffering, in most cases is just a lazy way of masking a problem instead of actually fixing it. And it adds more processing/overhead to each page and more importantly consumes memory that could push a large program over the limit of available memory. It also delays the output of the HTML to the browser, so the browser must wait to start rendering a page when it could already be processing elements on the page. You should only use output buffering if you want to buffer output, not to mask errors (it will also mask php error messages that are output to the browser when you then do a redirect, so it also hinders troubleshooting.) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.