-
Posts
3,145 -
Joined
-
Last visited
-
Days Won
37
Everything posted by cyberRobot
-
I'm assuming that's not your entire class definition. Does your complete class have a __construct() method? If not, the FileStorage() method may be used as the constructor and be called twice. Also note that the echo statement isn't going to do anything since FileStorage() doesn't return a value.
-
$pwdfailure is no longer in scope once you leave the function. You could try something like this: if($pwdfailure = password_strength($_GET['password'])) { echo $pwdfailure; // I tried this } else { echo 'Password good'; } Also note that the following if test doesn't do what you expect: if (!preg_match("[^\da-zA-Z]", $password)) { // no lower $pwdfailure = "Password must contain a SPECIAL character."; return $pwdfailure; }
-
More information about arrays and the foreach loop (including examples) can be found here: http://www.php.net/manual/en/control-structures.foreach.php
-
So the mystical number (67) is coming from a call to strlen()? If that's the case and you need the value for later, did you try storing the value in a variable? $stringForToken = strlen($str);
-
Is the page named with a .php extension? Note that PHP isn't parsed in .html files...unless the server is configured to do so.
-
Have you tried one of the many tutorials online: https://www.google.com/search?q=php+build+an+online+poll If you're not comfortable with PHP, you could use a third-party solutions like Google forms: https://support.google.com/drive/answer/87809?hl=en Or maybe a service like JotForm: http://www.jotform.com/
-
You got it. Note that you'll probably still get errors, but that's a good start.
-
The open PHP tag goes after the <body> tag here: <body>hexdec(substr($hexcolor,0,2)),'g'=>hexdec(substr($hexcolor,2,2)),'b'=>hexdec(substr($hexcolor,4,2))); Note that there are a number of other errors. However, some of those errors may be caused by where you got the code from. Did you copy the code from the original file? The reason I ask is the following line uses < instead of > while ($i < $characters) {
-
Did it return "true" as expected? Since the function return true/false, you could modify the if statement as follows: <?php if (login_check($mysqli)) : Also, note that the function could be simplified. Instead of having all those return statements, you could do something like: <?php //... if ($login_check == $login_string) { // Logged In!!!! return true; } } } } // Not logged in return false; } ?> Also note
-
Could you show what the login_check() function look like? Of course, if there is any sensitive information in the function, you'll want to hide that. Have you tried displaying the value that's returned by login_check()? Maybe it doesn't return a true/false value. You could add the following line above your if statement: var_dump(login_check($mysqli));
-
$result will only contain false if the query failed. Otherwise it returns a result set which will evaluate to true. Even if there were no matches for the query, it still returns a result set. The query was successful; there just weren't any matches. You could test if any rows were returned. if(mysql_num_rows($result)) { while($row = mysql_fetch_array($result)) { More information about mysql_num_rows() can be found here: http://www.php.net/manual/en/function.mysql-num-rows.php
-
What does the code for formatting.html look like? As the code stands, the login_check() function is missing and $mysqli is undefined.
-
Assuming that the is_bot() call is supposed to be isBot(), you could just use "else" instead of running the function twice. if(isBot()) { echo 'bot'; } else { echo 'human'; }
-
is_numeric if one of the inputs isn't numeric then echo message!
cyberRobot replied to oobradersoo's topic in PHP Coding Help
Side note: Are you okay with values like "4e1" and "3.1" being valid numbers? If not, you could use ctype_digit() instead of is_numeric(): http://www.php.net/manual/en/function.ctype-digit.php- 8 replies
-
- php
- is_numeric
-
(and 2 more)
Tagged with:
-
I'm not sure if this is the same font, but have you considered using Google Fonts: http://www.google.com/fonts#UsePlace:use/Collection:Dancing+Script
-
So it sounds like everything appears to be working except for the header redirect. In addition to making sure that your script is reporting all errors and displaying them (as mac_gyver suggested), have you tried using an absolute link in the header() function? header("Location: http://www.yourwebsite.com/welcome.php"); Of course, you'll need to modify the address to match where the page is on your website. Also, are you familiar with what's going on in the configuration file? include('config.php');
-
Perhaps the image tag isn't pointing to the right folder. Have you tried using root-relative links? $image = "<img src='/image/$picture' height='100' width='100' />"; Note that I added the slash before the "image" folder. Of course, your image folder may not be in the root director. You'll need to modify the path to match where the images are being uploaded.
-
Note that you can check if the query returned matches by adding the echo statement below: //... $result= mysql_query($sql) or die(mysql_error()); echo 'Number of matches: ' . mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($row = mysql_fetch_array($result)) { header("Location: welcome.php"); exit; } //...
-
Does your database contain an entry which has the username set to "admin" and the corresponding password set to "admin"?
-
No problem Have you tried echoing something inside the if construct? For example <?php include('config.php'); // @ob_start(); if (isset($_POST['submit'])) { echo 'here'; //... If it displays "here", try displaying the SQL query: $sql = "SELECT * FROM users WHERE username='$myusername' and password='$mypassword'"; echo $sql;
-
When you submit the form, what happens? Does the form appear again, does it display a blank page, etc.?
-
Did you try Mace's suggestion? http://forums.phpfreaks.com/topic/285553-login-form-not-working/?do=findComment&comment=1466008 Note that you'll need to comment out the output buffering line.
-
That undefined variable message comes from the following line: $stmt = $mysqli->prepare($prep_stmt); Based on a cursory look, you don't need that line. The script calls the prepare() method later. if (empty($error_msg)) { // Insert the new user into the database if ($insert_stmt = $mysqli->prepare("INSERT INTO walkin (username, fname, lname, msisdn, email, query1, creation_time) VALUES (?, ?, ?, ?, ?, ?, now())")) {
-
Perhaps you're getting a SQL error. As written, the code won't show the errors since output buffering is turned on. Try commenting out the ob_start() function: <?php include('config.php'); // @ob_start(); if (isset($_POST['submit'])) //...
-
Did you try displaying the POST variables to see if they contain what you expect? For example, you could trying something like this: <?php print '<pre>' . print_r($_POST, true) . '</pre>'; include('config.php'); @ob_start(); if (isset($_POST['submit'])) //... ?> Note that you'll probably see some errors when the form first appears. But the form information should be displayed once the form is submitted. Also note that you'll want to check out the following article regarding the use of PHP_SELF as the form action: http://seancoates.com/blogs/xss-woes