HuggieBear
Members-
Posts
1,899 -
Joined
-
Last visited
Everything posted by HuggieBear
-
OK, in that case, try leaving the value field as either blank, or FALSE [code=php:0]setcookie(ID_my_site, "", time() - 3600);[/code] Regards Huggie
-
OK, here's a complete code, assuming that the fields in your form are called username and password and you're using the post method. [code]<?php // Have the username and password been filled out if (!empty($_POST['username']) && !empty($_POST['password'])){ // Query the database $sql = "SELECT username FROM users WHERE username = '{$_POST['username']}'"; // Check if we got a result returned $result = mysql_query($sql); if (!$result){ echo "Couldn't execute: $sql<br><br>\n" . mysql_error(); } else { // Does the user exist, how many rows were retrurned if (mysql_num_rows($result) > 0){ echo "Username already in use\n"; } else { echo "Username doesn't exist\n"; } } } else { // Your code to echo the form goes here } ?>[/code] Regards Huggie
-
I'd create a separate table in my database called memberTypes, it has two columns, the first is called id, is unique, and is auto incrementing and the second is called type. Insert the rows into it 1 Manager 2 Supervisor 3 Floor Manager Then on your page, you want to generate the dropdown menu like this: [code]<?php // Print the start of the select code echo "<select name=\"type\" id=\"type\">\n"; // Query the database for values $sql = "SELECT * FROM memberTypes"; $types = mysql_query($sql) or die ("Can't execute: $sql<br>\n<br>\n" . mysql_error()); // Output a row for each field in the database while ($row = mysql_fetch_array($types, MYSQL_ASSOC)){ echo "<option value=\"{$row['id']}\">{$row['type']}</option>\n"; } // Print the end of the select code echo "</select>\n"; ?>[/code] This way, you can add as many rows as you like to the memberTypes table, in case you need to create new types in the future and they'll appear in the page without having to re-write any php. Regards Huggie
-
This question is too ambiguous, it's really related to the data the query's bringing back. Look at these two queries: SELECT id FROM table_name WHERE unique_value = 1 LIMIT 1 SELECT * FROM table_name Now imagine that my table has 45 million rows in it 20 columns. The first piece of code is going to execute relatively quickly and is returning one piece of information, the second will take a very long time as it's trying to return 900 million pieces of information. I don't see that there's a problem with having lots of calls to mysql_query() on a page, but try to keep your code efficient. Regards Huggie
-
Can you please post the line of code that sets the cookie? Regards Huggie
-
Try [code=php:0]error_reporting(E_ALL);[/code] at the top of your script Regards Huggie
-
Try changing this: [code=php:0]$query = "select username from accounts where username='[username]'";[/code] To this: [code=php:0]$query = "select username from accounts where username='{$_POST['username']}'";[/code] Regards Huggie
-
Are you able to provide us with any code that you've created? Regards Huggie
-
Simple Web Form To Access/Modify MySQL Database?
HuggieBear replied to Greenie's topic in PHP Coding Help
As far as I'm aware, it's the most widely used web based tool, for managing MySQL databases, in fact, it's probably the most widest used full stop. It should be simple to install if you have PHP installed on the server, there are some pre-requisites as far as I'm aware, but nothing too troublesome. Regards Huggie -
Simple Web Form To Access/Modify MySQL Database?
HuggieBear replied to Greenie's topic in PHP Coding Help
Is there something wrong with PhpMyAdmin? It will have all the features you need and more. If you insist on using your own, then just use mysql_query() and issue a SHOW TABLES FROM [i]dbname[/i] Regards Huggie -
created objects owned by httpd how can I avoid this?
HuggieBear replied to Nomax5's topic in PHP Coding Help
My advice would be to contact ixwebhosting.com in the first instance and find out if there's anything they can advise, as this isn't a PHP related issue, rather an issue with the way they have their server set up. Regards Huggie -
Forgetting the syntax colouring, does it look OK in a browser? Most syntax wont look correct if it appears inside and echo tag. Especially HTML code. Regards Huggie
-
The form is there! The problem is not with your PHP it's with your layout. It's not visible as your layout is incorrect. If you open in the source in IE and do a search for 'title' you'll see that the form code is visible in the source. I can only assume this is due to either your table layout or your style sheets. Regards Huggie
-
This can't be all the code as there's no buttons for Update and Delete here. Are you able to provide all the relevant code for that page? Regards Huggie
-
It can also add to the security features by using LIMIT, even if you know there's only going to be one row. If you've forgotten to sanitise your input by using something like mysql_real_escape_string() then it will limit the damage. Take the sql you have there as an example... [code=php:0]$query = "UPDATE `user_system` SET `msn` = '$msn', `icq` = '{$icq}', `aim` = '{$aim}', `email` = '{$email}' WHERE `user_system`.`id` = '{$member_id}'";[/code] Now imagine that I passed [color=red]%' OR ' '=' [/color] as the [color=green]member_id[/color] parameter. That's going to make my SQL look like this: [code=php:0]$query = "UPDATE `user_system` SET `msn` = '$msn', `icq` = '{$icq}', `aim` = '{$aim}', `email` = '{$email}' WHERE `user_system`.`id` = '%' OR ' '=' '";[/code] By my calculation that's going to corrupt every single row in your database, by putting LIMIT in there, only one line at a time can be destroyed. Regards Huggie
-
I would have thought that MySQL's functions would be better for this. I can't get to the MySQL manual at the minute, but something like this I'd imagine: [code=php:0]$sql = "SELECT curtime() - time_column AS difference FROM timetable";[/code] This will give you the difference in seconds between the two times. Regards Huggie
-
Please post your code and we'll try to point you in the correct direction. Regards Huggie
-
Firstly, it would be a good idea if you posted your code, this would allow us to help you better, and secondly, try to explain things in a little more detail, as this description is a bit ambiguous... "I have a loop of messages". Do you mean that you're pulling results from a database and using a loop to output them all? Then you want the checkbox that's output next to them to delete the record from the database? Regards Huggie
-
Hmmm, that's quite interesting, it looks as if the captcha device is working OK, and sensibly it doesn't have the security code in the page code anywhere, only an ID that I guess links into a database. Are you sure the signups are being created by bots? Regards Huggie
-
Do you have the URL so we can take a look at the signup page? Regards Huggie
-
I would have thought so out of the box, but you could ask them to create some code on their site which allows you to query their database? Regards Huggie
-
Is there any way to decrypt a password in phpmyadmin
HuggieBear replied to DeathStar's topic in PHP Coding Help
It depends on how it was encrypted. There are what's known as one-way encryptions, not designed to be decrypted, there's things like md5 which can sometimes be broken using brute force tactics and there are some that are designed to be used to both encrypt and decrypt. Regards Huggie -
In this instance, coincidently, it is probably AJAX that you're after for this task, but as Thorpe mentioned earlier, this isn't always the case. I'd suggest visiting PHP Freaks sister site, [url=http://www.ajaxfreaks.com/]AJAX Freaks[/url] for beginner tutorials on this sort of thing. Regards Huggie
-
What happens if you use: [code]SELECT username, userlevel FROM users WHERE username = 'tom' AND password = 'xxxxxx'[/code] I just wondered why you're specifying the table in the WHERE clause? Regards Huggie