
wisewood
Members-
Posts
226 -
Joined
-
Last visited
Never
Everything posted by wisewood
-
Problem with membership and login script.......
wisewood replied to lssjg's topic in PHP Coding Help
gmail should have smtp details somewhere in the settings for the account (if you have one) as they allow you to set up your gmail account in your favourite mail software. -
SELECT * FROM your_table WHERE your_field LIKE '%$variable%' ORDER BY whatever_field
-
have you tried using SELCT * instead of SELECT admin... ?
-
How to find MYSQL Database location with PHP
wisewood replied to yumico23's topic in PHP Coding Help
if you look through the php files for where the connection is made, this will give you information such as "localhost", "username", "password". Have you tried running [a href=\"http://your_server/phpmyadmin\" target=\"_blank\"]http://your_server/phpmyadmin[/a] ? -
I may have misunderstood, as it seemed obvious... so let me know if i'm wrong. [code] echo '<center><TABLE Border="1" Cellpadding="0" Cellspacing="0">'; echo '<TD BGCOLOR ="#F8F8F8" WIDTH=200 HEIGHT=150 ALIGN=CENTER valign="top" align="center"><a align="middle" href="/info.php?id_pic='.$id.'"><img src="' . $description . '" /></a><br>'; echo ' '.$com.'<br>Rating: '.$rates.'<br> Total Comments: '.$Total2.'<br><br></td>'; [/code]
-
Can't share SESSION variables. I need some help!
wisewood replied to mmtalon's topic in PHP Coding Help
This works for me. You seemed to have un-necessary bits in there. <?php session_start(); // page1.php $_SESSION['grncolor'] = 'green'; echo $_SESSION['grncolor']; // output works here echo session_id(); // outputs session_id // passing the session id - also tried absolute path with same results echo '<br /><a href=../bb/page2.php>page 2</a>'; ?> <?php session_start(); // page2.php //tried if(isset($_SESSION['grncolor'])) { negative } echo $_SESSION['grncolor']; // green - will not output a value echo session_id(); // outputs same session_id as in page1.php echo '<br /><a href="../aa/page1.php">page 1</a>'; ?> -
instead of using $date as the value to insert, use NOW(). This will generate a properly formatted date/time stamp for you... or at least it does with my setup. [code] mysql_query("INSERT INTO `company_news` (date, sender, title, message, company) VALUES ('NOW()', 'Updater', 'Company Name Updated', 'Your companys name has been updated to $name.', '$name')"); [/code]
-
During the development on the system i am working on for client management here, there have been loads of instances of me thinking "we don't really need this, but for my own amusement i will add it anyway" and then a few days later, while working on something completely unrelated the code has been really useful. It's quite good to make things as indepth as possible sometimes, because you never know how things will pan out. In 6 months time it'd be easier to be able to just "turn on" some code that's already in place, than to have to try and bolt on something to do the job later. This has actually given me an idea for something i am working on... thanks for that lol.
-
Select date range from timestamp with php and mysql
wisewood replied to oli_62's topic in PHP Coding Help
I have this very same thing on my intranet system. I used the mktime() function. if you want to search between 2006-18-04 16:40:22 and 2006-19-04 16:40:22 (between now and this time tomorrow) you would use this [code] <?php $start = mktime(16, 40, 22, 04, 18, 2006); $end = mktime(16, 40, 22, 04, 19, 2006); $query = "SELECT * FROM your_table WHERE time_stamp > $start AND time_stamp < $end"; // etc etc etc ?> [/code] This will select from your_table all entries where the time_stamp field is greater than the timestamp for the $start variable and less than that timestamp for the $end variable. Hope this helps you on your way. -
Don't worry... ken knows more clever stuff than i do
-
You could even set the "This can't be edited" message to incorporate the time when they will be able to edit it... ie "You cannot edit this record until 16:38" If you wanted to be really cocky you could let them be notified when the record became available for editing, and if multiple people are waiting to edit the record, have them held in a queue lol
-
Problem with login page (accessing 2 tables)
wisewood replied to OriginalSunny's topic in PHP Coding Help
I wouldn't use seperate tables for users and admin. Have one table for users, and an authorisation level field within that table. ie. userID, username, password, authLevel authLevel can then be set as 1 for users, 2 for admin and 3 for super-admin... or whatever you like. Then, if you want a page to be visible ONLY to the user to whom it is relevant, have the $_SESSION[username] variable set when they log on... and you can have a query like "SELECT * FROM users WHERE username = $_SESSION[username]" admin could access the same page by using a form or a list to select the name of the user for whom they'd like to view the details... ie "SELECT * FROM users WHERE username = $_GET[username]" Hope this helps. -
use an "is_locked" field. When the edit page is opened, have an update query run and set is_locked to time() When the edit is completed, have the update query run and set is_locked to nothing ... ie "" If the timespan for the file to be edited has elapsed, which for example could be 5 minutes... just allow it to be edited. Something like; [code] <?php $time_now = time(); $allowed_time = $time_now-300; if($is_locked<$allowed_time) { echo "Editing is allowed"} [/code] Obviously this would need fleshing out, but you get the idea.
-
could you not have an additional field in your table named "is_numeric" or something? This way you could just run two queries... select * from your_table where is_numeric=0 //show the results then select * from your_table where is_numeric=1 You could have a script running on the variable before its inserted into the database to decide whether it contains any non numeric characters or not.
-
I hope I understand you correctly. If so, this will do what you want. [code] <?php // Your original data $expires = "2006-04-17 09:54:23"; $months = "6"; // Break the $expires variable into component parts $year = substr($expires, 0, 4); $month = substr($expires, 5, 2); $day = substr($expires, 8, 2); $hour = substr($expires, 11, 2); $minute = substr($expires, 14, 2); $second = substr($expires, 17, 2); // Add $months onto $month $new_month = $months+$month; // If $new_month is only 1 digit, add a preceeding zero $strlen = strlen($new_month); if($strlen==1) {$new_month = "0$new_month";} // Set the $expires variables with the new value $expires = "$year-$new_month-$day $hour:$minute:$second"; // Just so you can see that it works... echo the result. echo "$expires"; ?> [/code]
-
What you need to do, is use the POST[username] and POST[password] variables in your query to the database. If the database finds a result for that username and password combination, THEN set the session variable with the username. [code] session_start(); $query = "SELECT * FROM users WHERE username='$_POST[username]' AND password='$_POST[password]'"; $result = mysql_query($query); if($result=="1") { $_SESSION[username]=$_POST[username]; echo "Hello $_SESSION[username], you're logged in"; } else { echo "Thou art imposter!"; } [/code] Once the session variable is set, you can then use that as your security measure... each page that you want protected should have something like this [code] <?php session_start(); if(!isset($_SESSION[username])) { echo "go away"; } else { // Your content here. } ?> [/code] Send me a PM if you want any further help & I'll send you the code for the login procedure i use.
-
ORDER BY jobcard DESC ?? Or is that too easy?
-
Showing "Open" or "Closed" based on hours in a db?
wisewood replied to bpottle's topic in PHP Coding Help
happy to help. I'll probably use it myself at some point. -
I was just about to try it with an update, saved me the trouble :-) Its a much better way to go about it as you can just stick that bit of the code in an included file and forget about ever having to mess around with insert & update queries ever again. Much time-saving! Ta.
-
that is a REALLY clever way of generating the query. *copy & paste to my repisitory*
-
Something like this should give you a clue. Put this in the head section of the document which contains the popup. <script type="text/javascript"> <!-- function redirect(){ window.location = "your_document.php?id=<?=$_GET[id]?>" } //--> </script> you can then use onClick='redirect();' assigned to whatever you want, and it'll redirect you to the apge specified in the window.location. Hope this helps. PS. If you need to do a javascript popup, just google it.
-
Are you sure you have all the field names spelled correctly, this is something that i still get wrong from time to time and it is always about the 40th thing i think to check.
-
How many "Faults" are there in the faults table? In phpmyadmin if you select that table, and then select the "operations" link at the top, it will give you a page which tells you what the next auto-increment value is. Is this a number close to the seemingly random number you got from the mysterious entry into the other table?