-
Posts
1,698 -
Joined
-
Last visited
-
Days Won
53
Everything posted by maxxd
-
alert(f) ALERTS "correct" BUT if(f=='correct') doesn't work!?
maxxd replied to slj90's topic in Javascript Help
Did you get this working? If not, print the contents of f to your console and check it there. If the status isn't 'correct', but for instance, "you are correct, sir or ma'am!", then my code wont' work because it's checking equality. However, your code would work because the word 'correct' is present in the string somewhere after the first letter of the string. It's also possible that the JSON output from forgotpasswordcheck.php isn't being parsed in JavaScript before the check is made. -
Page element display is a CSS issue. If, by "links selected", you mean links that the user has already visited, use the 'a:visited' selector in your CSS file. If you mean the links to which you attach the class 'selected', you'd want to define that class in your CSS file. Also, please use the code tags in the post editor ("< >" on the toolbar) when posting code to the forum - it makes everything much easier to read.
-
Right, and that's why we're asking you to supply the surrounding code. $row['category'] either isn't being set, or it's being set incorrectly. However, without the surrounding code, there's no way to tell where, how, or why.
-
What's the surrounding code? Given the variable name $row, it's possible the code is trying to run the select query inside a loop, which isn't a good idea. If that is what's actually happening, you're probably going to want to rework the initial query to use a join in order to bring back the entire record set with a single call to the database.
-
Random aside here - Barand, I'd never (as far as I can recall, anyway) heard of the levenshtein() function. Thank you - that's kinda awesome!
-
You're going to need to create a role-based access structure. Basically, you create a new table that stores role name, role level, and role ID. Then add a role ID foreign key column to your user table and use that for comparison. You'll also need to create a method of checking the user access role when that user loads a page - anyone can type an address into the browser's location bar, so once the user is there you have to confirm the fact that they're actually allowed to be there. There's about a million and four debates around the web about handling role-based access systems, so there's no dearth of information or opinion on the matter. Google and spend some time reading. What's below is certainly not the most elegant refactoring of your code, but at it's basest it should get you moving in the right direction. if(isset($_POST['login']) && !empty(trim($_POST['login']))){ $username = stripslashes($_POST['username']); $password = stripslashes($_POST['password']); $stmt = $pdo->prepare(" SELECT u.password ,u.status ,r.roleName FROM tablename u LEFT JOIN tableroles r ON u.roleID = r.ID WHERE u.username = :username "); $stmt->bindValue('username', $username, PDO::PARAM_STR); $stmt->execute(); $pg = 'badLogin.php'; if($stmt->rowCount() === 1){ $row = $stmt->fetch(PDO::FETCH_OBJ); if(!password_verify($password, $row->password)){ header("location:{$pg}"); exit; } $_SESSION['username'] = $username; if($row->roleName == 'ADMIN'){ if($row->status == 'COMPLETED'){ $pg = 'completed/admin_index.php'; }else{ $pg = 'uncompleted/admin_index.php'; } }else{ if($row->status == 'COMPLETED'){ $pg = 'completed/index.php'; }else{ $pg = 'uncompleted/index.php'; } } } header("location:{$pg}"); exit; }
-
alert(f) ALERTS "correct" BUT if(f=='correct') doesn't work!?
maxxd replied to slj90's topic in Javascript Help
In your php file, echo a json-encoded array and check those values in your javascript. Along the lines of: ... echo json_encode(array('status'=>'correct')); ... and in your JS: if(f.status == 'correct'){ ... -
Just some quick advice - break this out into another thread. Your original issue is solved and this one is new; as a new thread you'll probably get more traffic (and hopefully help). Now, to the posted code. I'm assuming there was a copy/paste error with the 'full page setup', because you've got raw PHP in your HTML. Also, it looks like you're attempting to pass the value of the .message form field to the php script via AJAX, but you're using the value from $_SESSION, which is set in the chunk of code not contained within <?php and ?>. And I'm assuming that core/init.php calls session_start(), because I don't see that anywhere. Are you getting any errors?
-
Could you explain what you mean by 'it says that the query is wrong'? What I see right off the bat is that you don't appear to be calling session_start() before using $_SESSION, but without more information I have no idea if that's the issue or if you didn't copy/paste the session_start() call.
-
Try changing 'top:' to 'margin-top:' and see if that fixes your issue.
-
Barand is correct about why your click event isn't triggering, but you can still assign the handler on page load using .on(). For instance $(document).on('click','form-submit',function(){ ... }); Side note: most of the time it works if you just attach the on to the specific DOM element, but sometimes you have to attach it to document and specify the DOM element in the function call. I'm sure there's a good reason for it, but I've never been able to figure it out...
-
Have you tried this? $('.tab-content div.tab').eq($('#tab-menu > li').index(this)).slideDown('slow'); Apparently you'll also get a performance boost (http://api.jquery.com/eq-selector/).
-
Help with PHP Mailer Contact form undefined variable
maxxd replied to Ricky55's topic in PHP Coding Help
The first time you use $message, it's not defined yet, so you can't concatenate (the period is a concatenation operator if PHP). So, where you've got $message .= "How can we help: {$_POST['help']} \n\n"; Should be either $message = "How can we help: {$_POST['help']} \n\n"; or $message = ""; $message .= "How can we help: {$_POST['help']} \n\n"; -
It looks like you're using $query in your SELECT query without actually initializing the variable or setting any value to it. Turning on error reporting as ginerjm suggests will tell you if that's the issue.
-
CRON jobs are set to run at set times of day (for instance, 15 minutes after every hour, or 7 minutes after every third hour. or 12:15), so when your user creates the e-mail and sets up the send time you can either present them with a drop-down of acceptable times, or set up your select in the script that's going to be run via CRON with a time range. Obviously the first suggestion is going to be more specific and truthful to your end user - if a user schedules a message to be sent in 10 minutes, but they schedule it at the beginning of the 15-minute select range, the CRON script will pick it up and send the message immediately, which is not the desired action. Please note that this is a ridiculously simplified 'explanation' of how CRON works and what type of schedules you can create with it.
- 4 replies
-
- php
- javascript
-
(and 2 more)
Tagged with:
-
Prevent some duplicate entries into database
maxxd replied to SalientAnimal's topic in PHP Coding Help
Hang on, I'm confused (proving Csharp's point in the process). So, you want to allow a single user to register multiple cell numbers? What does that have to do with green cards or passports? If you're attempting to associate multiple cell phones with a single user, break the cell phone number column out into a separate table and link the records via the auto-incremented user ID from your user table. This user ID won't be a green card number or passport number or even cell phone number, but an internal, database-generated identification number that the end user never sees - it's used specifically for linking records between tables (for instance, the user and cell phone tables), and ensuring that whatever action you're about to perform on a record in the table is being performed on the correct record. You could even add another column to the user table that specifies what type of number the user is using for the public-facing identification (cell phone, green card, passport, library), which might make whatever logic you're using a bit more transparent. -
You'll want to set up a CRON job to take care of this. Basically, you save the e-mail information and the time the user wants to send the email into a database table, write a script that pulls all the messages that haven't been sent yet but are scheduled to send now(ish), and send them. You then schedule a CRON on the server to run every 15 minutes or so that runs this script. I'm not sure I'm explaining this terribly well (sorry), but Google CRON jobs and that should get you moving in the right direction.
- 4 replies
-
- php
- javascript
-
(and 2 more)
Tagged with:
-
Try dumping the contents of $post after the query is run, and the value of $args after the explode() call ($args is just what I called the resulting string, btw). Make sure it's actually got all the correct information and that the information is formatted properly. Also, make sure you've got error reporting turned on.
-
Couple things right off the bat - I'm not sure where $property_title is being assigned, but unless it's escaped elsewhere you're leaving yourself open to SQL injection. Also, are you printing the post_ids as a test or are you attempting to create the string as grissom suggests? Give this a shot - $post = $wpdb->get_results($wpdb->prepare( "SELECT post_id FROM sw_images_upload WHERE property_title = %s", $property_title ), ARRAY_N); if($post){ $args = implode(',',$post); //concatenate the results into a string, each value separated by a comma } echo do_shortcode("[gallery include='{args}']"); Basically, this is using WordPress's version of a prepared statement (not a true prepared statement, but at least you're not putting $_REQUEST data directly into a query) to return a numerically indexed array of post_ids that match your property_title. implode() is base php that does exactly what grissom suggests about making the array a string. Then you inject that string into your shortcode. I don't guarantee this will work if it's just cut and pasted into the functions file, but hopefully it'll point you in the right direction. Oh - and also, please use the code button ("< >") on the editor to post code. It makes it much more readable.
-
Assuming the boss info is stored in another table in your database, you'll want to join the tables in your query. So, basically, if the table 'raidboss_spawnlist' contains the columns boss_id and respawn_time and table 'boss_information' contains the columns boss_id and boss_name, you'd join the two on the column boss_id (it's a foreign key) like this: SELECT b.boss_name ,a.respawn_time FROM raidboss_spawnlist a LEFT JOIN boss_information b ON a.boss_id = b.boss_id ORDER BY respawn_time DESC Of course, this is all moot if you don't have the boss information set up in a separate table; however, if you don't then you should reconsider your database design.
-
You're not separating the numbers. If you look at your example, you've got [gallery include="499,496"] but your built string is reading [gallery include="499496"] Try changing the do_shortcode() call to echo do_shortcode("[gallery include='{$image1},{$image2}']"); Note the comma separator between the variables.
-
Yeah, I don't see where $curly is defined before you're trying to print the footer. What theme are you using - I assume the curly() method overwrites WordPress's native get_footer() method.
-
It's difficult to tell with the formatting of the code, but I think you may be missing an endif; at the end of your code. You've got if(comments_open()){ followed by if (get_option(THEMEPREFIX.'_fb_comments') != "true" ) : comments_template(); else : ?> but then only one 'endif;'. Again, given the formatting it's difficult to tell (and I hate how much WP encourages mixing PHP and HTML and the if(): endif; syntax, but that's neither here nor there), but that could be it. I'm assuming you can't remember exactly what it was that you changed?
-
There are several issues with the code you've posted, actually. First and foremost, your quote nesting is incorrect and you're leaving plaintext strings in the middle of the echo statements. Also, the php open/close tags don't match up in several places. <?php if ( is_single() ) { echo "<div class='pagelink'>".wp_link_pages('pagelink=trang %')."</div><p>"; echo "<div class='fb-like' data-href='https://www.facebook.com/tvvn.net' data-layout='standard' data-action='like' data-show-faces='false' data-share='true'></div><p>"; if(function_exists("kk_star_ratings")){ echo kk_star_ratings($pid); } echo "<p>".do_shortcode("[kpvc_single]"); echo "<p>".do_shortcode("[fbcomments]")."<p>"; zemanta_related_posts(); } else {} ?> This just fixes the syntax errors in the code you posted - there's no logic work done in the above. For instance, I'm not seeing where $pid is being defined, so if it's not done somewhere higher up in the script, you'll get an undefined error assuming that function kk_star_ratings() exists. I'm not familiar with the Zemanta Related Posts plugin, so I don't know if zemanta_related_posts() will display to screen without an explicit echo statement.