lacho898 Posted December 9, 2013 Share Posted December 9, 2013 Hi Guys, I have this code; <html> <head> <style> stuff { color:#FFF } </style> </head> <body> <div id='stuff'> <?php session_start(); include('configdb.php'); if(isset($_POST['submit'])) { //whether the username is blank if($_POST['username'] == '') { $_SESSION['error']['username'] = "User Name is required."; } //whether the email is blank if($_POST['email'] == '') { $_SESSION['error']['email'] = "E-mail is required."; } else { //whether the email format is correct if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $_POST['email'])) { //if it has the correct format whether the email has already exist $email= $_POST['email']; $sql1 = "SELECT * FROM user WHERE email = '$email'"; $result1 = mysqli_query($mysqli,$sql1) or die(mysqli_error()); if (mysqli_num_rows($result1) > 0) { $_SESSION['error']['email'] = "This email address is already being used."; } } else { //this error will set if the email format is not correct $_SESSION['error']['email'] = "Your email address is not valid."; } } //whether the password is blank if($_POST['password'] == '') { $_SESSION['error']['password'] = "Password is required."; } if(strlen($_POST['password']) < 6){ $_SESSION['error']['password'] = "Password is too short"; } if(isset($_SESSION['error'])) { header("Location: index.php"); exit; } else { $username = $_POST['username']; $email = $_POST['email']; $password = $_POST['password']; $tester = $_POST['tester']; $com_code = md5(uniqid(rand())); $sql = "INSERT INTO user (`username`, `email`, `password`, `tester`, `com_code`) VALUES ('$username', '$email', '$password', '$tester', '$com_code')"; $result2 = mysqli_query($mysqli,$sql) or die(mysqli_error()); if($result2) { $to = $email; $subject = "Confirmation from Husha Innovations"; $header = "Husha Innovations: Confirmation"; $message = "Please click the link below to verify and activate your account. rn"; $message .= "http://www.hushainnovations.comule.com/confirm.php?passkey=$com_code"; $sentmail = mail($to,$subject,$message,$header); if($sentmail) { echo "Your Confirmation Link Has Been Sent To Your Email Address."; } else { echo "Cannot send Confirmation link to your e-mail address"; } } } } ?> </div> </body> </html> However, all my text appears in black writing which is not good if you have a black background for your website. I have managed to change the colour of the echo's but not in the places like $_SESSION['error']['password'] = "Password is required."; Any ideas? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/284638-changing-text-colour-of-an-error/ Share on other sites More sharing options...
hitman6003 Posted December 9, 2013 Share Posted December 9, 2013 Why wouldn't you change the text color using CSS? <style> body { color: #FFFFFF; } Quote Link to comment https://forums.phpfreaks.com/topic/284638-changing-text-colour-of-an-error/#findComment-1461728 Share on other sites More sharing options...
lacho898 Posted December 9, 2013 Author Share Posted December 9, 2013 Tried that and it only change the text colour of echos not other text Quote Link to comment https://forums.phpfreaks.com/topic/284638-changing-text-colour-of-an-error/#findComment-1461730 Share on other sites More sharing options...
hitman6003 Posted December 9, 2013 Share Posted December 9, 2013 What other text? The variable assignments aren't printed to the screen...the contents of the variable may/may not be echo'd or printed to the screen. I'm surprised that your sessions and redirect headers are working since there is data being sent to the browser before those are called. Quote Link to comment https://forums.phpfreaks.com/topic/284638-changing-text-colour-of-an-error/#findComment-1461732 Share on other sites More sharing options...
lacho898 Posted December 9, 2013 Author Share Posted December 9, 2013 Ok.... please slow down. This is supposed to be a membership signup and this file is supposed to take the input from a file called index.php. As you can see in this file, there is some validation arguments in the code. If for example the username if left blank the file posts some text on to the page. That text is black and therefore can't be seen. I want to make it white and I don't know how Quote Link to comment https://forums.phpfreaks.com/topic/284638-changing-text-colour-of-an-error/#findComment-1461733 Share on other sites More sharing options...
Ch0cu3r Posted December 9, 2013 Share Posted December 9, 2013 The solution is to use a site wide stylesheet which sets the text color to white for all html elements. Create a new file called style.css, and add the following to it html { background-color: #000; /* Set page background to black */ color: #FFF; /* Set page text color to white */ } Now in any page you want to set the page black, with white text you'd link to that stylesheet using <link rel="stylesheet" href="style.css" /> Quote Link to comment https://forums.phpfreaks.com/topic/284638-changing-text-colour-of-an-error/#findComment-1461756 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.