Jump to content

rEhSi_123

Members
  • Posts

    76
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Male

rEhSi_123's Achievements

Member

Member (2/5)

0

Reputation

  1. Thanks rille95 and mikesta707 for the correction as I should have know this..... Also mikesta707 what do you mean by this 'you can also have the query execute in the else statement if you dont want to use exit' sorry
  2. Hello Everbody I am have php website in which I have decided to add Testimonial section where visitors can leave feedbacks...etc.... Everything seems to be working fine where I am able to enter the data into the MySQL database. Anyways, basically I am trying to add a required field validator in order to prevent an empty form to be submitted into the database i.e. blank fields. I googled the above topic where I have come across Javascript validators ...etc but I want to stay away from it because of very less experience and since there is a possibility of browers with no javascript support. I have also tried the below: if ($_POST['name']=="") { Print("Please fill in all fields!<br>"); } elseif ($_POST['email']=="") { Print("Please fill in all fields!!<br>"); } elseif ($_POST['comment']=="") { Print("Please fill in all fields!!!<br>"); } else { echo "Successful"; echo "<BR>"; echo "<a href='viewguestbook.php'>View guestbook</a>"; } Where it displays a error message if the field is empty but blank data is still entered into the database Any suggestions please advice!
  3. Brilliant! :) :) :) :) :) :) I should have known this...... Problem resolved in both I.E 7 and Firefox! Thanks again
  4. You mean <td align=\"center\"> I have used the above but still luck..... The issue is if I dont use &nbsp then the text and textboxes are always on the left in FF3 and right in I.E7.0 ??? Even if set the properties in CSS or table
  5. my actual code looks like this before I removed the &nbsp before no matter what peoperties I set in my CSS i wans't able to center out my contents even FF3.0 so Had to use this make shift...... I basically want the contents inside the table to be centered! Yes please! Thanks echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<form method=\"post\" action=\"register.php\">\n"; echo "<p style=\"border:1px solid #C0C0C0;text-align:left;color:#660002;\"><a href=\"index.php\">MAIN |</a> Register - Please enter all the fields specified below!</p>\n"; echo "<tr><td class=\"user_login\"> Username</td><td><input type=\"text\" name=\"username\" style=\"background-color:#00FFFF;\"></td></tr>\n"; echo "<tr><td class=\"user_login\"> Password</td><td><input type=\"password\" name=\"password\" style=\"background-color:#C0D9D9;\"></td></tr>\n"; echo "<tr><td class=\"user_login\"> Confirm Password</td><td><input type=\"password\" name=\"passconf\" style=\"background-color:#C0D9D9;\"></td></tr>\n"; echo "<tr><td class=\"user_login\"> E-Mail</td><td><input type=\"text\" name=\"email\" style=\"background-color:#C0D9D9;\"></td></tr>\n"; echo "<tr><td class=\"user_login\"> Name</td><td><input type=\"text\" name=\"name\" style=\"background-color:#C0D9D9;\"></td></tr>\n"; echo "<tr><td class=\"user_login\" colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Register\"></td></tr>\n"; echo "</form></table>\n";
  6. echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<form method=\"post\" action=\"register.php\">\n"; echo "<p style=\"border:1px solid #C0C0C0;text-align:left;color:#660002;\"><a href=\"index.php\">MAIN |</a>Register - Please enter all the fields specified below!</p>\n"; echo "<tr><td class=\"user_login\">Username</td><td><input type=\"text\" name=\"username\" style=\"background-color:#00FFFF;\"></td></tr>\n"; echo "<tr><td class=\"user_login\">Password</td><td><input type=\"password\" name=\"password\" style=\"background-color:#C0D9D9;\"></td></tr>\n"; echo "<tr><td class=\"user_login\">Confirm Password</td><td><input type=\"password\" name=\"passconf\" style=\"background-color:#C0D9D9;\"></td></tr>\n"; echo "<tr><td class=\"user_login\">E-Mail</td><td><input type=\"text\" name=\"email\" style=\"background-color:#C0D9D9;\"></td></tr>\n"; echo "<tr><td class=\"user_login\">Name</td><td><input type=\"text\" name=\"name\" style=\"background-color:#C0D9D9;\"></td></tr>\n"; echo "<tr><td class=\"user_login\" colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Register\"></td></tr>\n"; echo "</form></table>\n";
  7. Cheers mate for your quick response...... But I had tried that earlier but didn't work either.... ..... It is funny that the screen contents are not aligned properly in IE7 but whereas everything is perfect in Firefox.... this is the CSS for my login .user_login { color:#000; font-weight:bold; font-family:Century Gothic; font-size:10pt; text-align:center; }
  8. Hello Guys, I have made a mini forum website and everything has being going well. But, I am now faced with one issue. In my login and register page all the text boxes are towards the right and the header on the top has also gone to the right...... ??? Whereas, everything seems fine in Mozilla Firefox, meaning the header is in the center along with the text boxes as I had it planned in my CSS file....... I have had this problem in the past where the contents of the pages dont sit correct in IE7. So was wondering if anybody here have had this problem in the past and if they could share the solution. Also I have used these in my CSS but no luck whatsoever. margin-left: auto margin-right: auto Please Help!
  9. Right finally problem resolved...... Now, all my connection settings are in globals.php but I had few functions stored in this file which were also same as in functions.php. So if I included both files then I would get an error saying The reason for technique is I am using them elsewhere in my php code....... therefore now, I have included the connection settings in my register.php which seems to do the trick Anways thanks for your help 'soak' Once more thing, would you suggest any other technique instead of renaming my functions.....
  10. hmmmm.....The above code is actually in my globals.php
  11. Soory for double post..... line 4 is basically this $string = addslashes($string); function protect($string){ $string = mysql_real_escape_string($string); $string = strip_tags($string); $string = addslashes($string); return $string; }
  12. I removed the connect function and got these errors Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\login\functions.php on line 4 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\wamp\www\login\functions.php on line 4 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\login\functions.php on line 4 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\wamp\www\login\functions.php on line 4 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\login\functions.php on line 4 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\wamp\www\login\functions.php on line 4 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\login\functions.php on line 4 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\wamp\www\login\functions.php on line 4 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\login\functions.php on line 4 Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\wamp\www\login\functions.php on line 4 Username is not defined! Password is not defined! E-mail is not defined! Name is not defined!
  13. I hope somebody could help me out! I have created a forum system and everything was running smooth untill i did some test runs....... Now, whenever a user goes to register, fills in the fields and clicks on Register button an error is displayed on the screen saying 'no database selected' I am pretty much sure that I have my connections all setup properly.....but still not able to find the problem. Could somebody please care to have a look.... Thanks Here is my code register.php <html> <center> <div id="holder"> <div id="userinfo"> <link rel="stylesheet" type="text/css" href="./style.css"> <?php error_reporting(E_ALL ^ E_NOTICE);//Report all error except NOTICES include_once "functions.php"; connect(); if ( empty( $_POST ) ){ echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<form method=\"post\" action=\"register.php\">\n"; echo "<tr><td class=\"user_login\" colspan=\"2\" align=\"center\">Registration Form</td></tr>\n"; echo "<tr><td class=\"user_login\">Username</td><td><input type=\"text\" name=\"username\" style=\"background-color:#00FFFF;\"></td></tr>\n"; echo "<tr><td class=\"user_login\">Password</td><td><input type=\"password\" name=\"password\" style=\"background-color:#C0D9D9;\"></td></tr>\n"; echo "<tr><td class=\"user_login\">Confirm Password</td><td><input type=\"password\" name=\"passconf\" style=\"background-color:#C0D9D9;\"></td></tr>\n"; echo "<tr><td class=\"user_login\">E-Mail</td><td><input type=\"text\" name=\"email\" style=\"background-color:#C0D9D9;\"></td></tr>\n"; echo "<tr><td class=\"user_login\">Name</td><td><input type=\"text\" name=\"name\" style=\"background-color:#C0D9D9;\"></td></tr>\n"; echo "<tr><td class=\"user_login\" colspan=\"2\" align=\"right\"><input type=\"submit\" name=\"submit\" value=\"Register\"></td></tr>\n"; echo "</form></table>\n"; }else { $username = protect($_POST['username']); $password = protect($_POST['password']); $confirm = protect($_POST['passconf']); $email = protect($_POST['email']); $name = protect($_POST['name']); $errors = array(); if(!$username){ $errors[] = "Username is not defined!"; } if(!$password){ $errors[] = "Password is not defined!"; } if($password){ if(!$confirm){ $errors[] = "Confirmation password is not defined!"; } } if(!$email){ $errors[] = "E-mail is not defined!"; } if(!$name){ $errors[] = "Name is not defined!"; } if($username){ if(!ctype_alnum($username)){ $errors[] = "Username can only contain numbers and letters!"; } $range = range(1,32); if(!in_array(strlen($username),$range)){ $errors[] = "Username must be between 1 and 32 characters!"; } } if($password && $confirm){ if($password != $confirm){ $errors[] = "Passwords do not match!"; } } if($email){ $checkemail = "/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i"; if(!preg_match($checkemail, $email)){ $errors[] = "E-mail is not valid, must be name@server.tld!"; } } if($name){ $range2 = range(3,64); if(!in_array(strlen($name),$range2)){ $errors[] = "Your name must be between 3 and 64 characters!"; } } if($username){ $sql = "SELECT * FROM `users` WHERE `username`='".$username."'"; $res = mysql_query($sql) or die(mysql_error()); if(mysql_num_rows($res) > 0){ $errors[] = "The username you supplied is already in use!"; } } if($email){ $sql2 = "SELECT * FROM `users` WHERE `email`='".$email."'"; $res2 = mysql_query($sql2) or die(mysql_error()); if(mysql_num_rows($res2) > 0){ $errors[] = "The e-mail address you supplied is already in use of another user!"; } } if(count($errors) > 0){ foreach($errors AS $error){ echo $error . "<br>\n"; } }else { $sql4 = "INSERT INTO `users` (`username`,`password`,`email`,`name`,`admin`,`time`) VALUES ('".$username."','".md5($password)."','".$email."','".$name."','0','".$time()."')"; $res4 = mysql_query($sql4) or die(mysql_error()); echo "You have successfully registered with the username <b>".$username."</b> and the password of <b>".$password."</b>!"; } } ?> </div> </div> </center> </html> my connection settings $host="localhost"; // Host name $username="root"; // Mysql username $password=""; // Mysql password $db_name="forum"; // Database name //$tbl_name="forum_question"; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); function connect(){ $con = mysql_connect("localhost", "root", "") or die(mysql_error()); $db = mysql_select_db("users", $con); }
  14. Sorry for being a dumb... Could please give me example?as ian still learning php. As my old message is in a array form... $row['message'] if u check my previous posts. Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.