|
Microsoft Windows |
|
Microsoft Word |
|
Microsoft Excel |
|
Photoshop |
|
Spletni programi |
|
Raznoraznarije |
|
|
|
Website User Registration in PHP |
|
|
|
|
|
|
|
We will make a PHP web page in which we will connect to MySql database, handle user authentication and show certain data only for registered users.
Link to the content ...
|
|
|
|
|
|
|
|
|
Hi, I have a question about the users table. Why did you used text for username and password instead of VARCHAR? |
|
|
|
|
|
|
|
|
TEXT is stored in the table as a pointer to the location of the actual text, while VARCHAR stores data directly in the table. So in theory VARCHAR is indeed a better choice.
But from practical point of view, the difference in performance is almost non-existant. On the other hand, for VARCHAR you need to specify maximum length. Since this is lesson for beginners, I have chosen TEXT, so that it will work in all cases.
I hope this answers your question. If you need any more info just let me know.
| changed: podtalje (29th Nov 2013, 2:25 PM) |
|
|
|
|
|
|
|
|
|
When I try the code I receive:
Fatal error: Call to a member function fetch_assoc() on a non-object in D:\wamp\www\login\index.php on line 14
Same goes for the Forum with PHP and MySQL .
Can you help me please?
| changed: julien gautar (7th Apr 2014, 7:45 PM) |
|
|
|
|
|
|
|
|
|
The code is failing on line $result->fetch_assoc().
The error is saying that $result is not an object. The reason for this is that it failed in the previous call which is: $sql="select * from users where username='$username'"; $result = $db->query($sql);
So it seems there is a problem with your query to the database.
One possible reason is that the connection to the database was not successfully established. Another reason might be that tables in the database are not correct.
To solve this problem, you should first try to run the query in the phpMyAdmin to see if it returns any result. Try using additional "echo $sql" in the code (after defining $sql variable) to see exactly what the query is.
I would also suggest that you add the following line at the top of the page after <?php error_reporting(E_ALL);
This will show you all errors and warnings.
|
|
|
|
|
|
|
|
|
|
|