![]() |
logging in
ok so im a bit stuck on this i have an assignment where i need to Start a session, and maintain it throughout, or until the user selects “logout” (for which a link must be provided). Ask the user’s name, and then display it on every subsequent page. i dont have anywhere on the database server where i can store the username so do i use cookies? im assuming i need to make a form and then save it to a cookie is this right?
any help greatly appreciated cheers ric |
If it's just a basic assignment and all you have to do is get that users name to be displayed until they choose to log out, it's really quite easy. I can't do it for you, because it's your homework, but I can nudge you in the right direction pretty far.
session_start() $_SESSION superglobal That should be all you need, along with $_POST and one form to ask them their name. One if statement and your logout can be taken care of in one method call too. -m |
Maybe I'm horribly out of the loop, but...Schools offer PHP otherwise known as web development classes?
On a related note, Delayed is right check out sessions or even cookies. |
Quote:
-m |
cheers guys got the log in bit working now, but the session start seems to be giving me an error Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /berw/ugrad1/base/r/rre7/public_html/sonicandtails/test.php:2) in /berw/ugrad1/base/r/rre7/public_html/sonicandtails/test.php on line 3
any ideas why its doing this |
thatll be the white space :-)
|
Get er fixed then?
|
Quote:
|
yeah got it half fixed cheers
|
i need to be able to let the user search my database and say for example i would like to search for games under £30, i know how to write the form but am not sure about the code in psuedo itd be something
like, if < is selected and input is 30 show results from table with price < 30 |
How is your data being stored, in a flat text file, or an SQL database?
|
in a sql database
|
SELECT field1, field2 FROM games WHERE price < 30
SELECT field1, field2 FROM games WHERE price BETWEEN 1 AND 30 unless you mean the PHP code PHP Code:
-m |
yeah its the php code. im checking on .net now but not having too much joy, the user needs to be able to specify the amount they want so it could be any amount, i need to take the out put from a txt field and use it to display the suitable results here is my page just so you see what i mean Sonic And Tails Online Game Shop "The One Stop Shop For All Your Gaming Needs"
cheers for your help by the way |
You should be able to use the value they enter into the form field (via $_POST['field']) and use that in your SQL query to determine what data to return. The only thing I would suggest on top of that, is validate your form input. Make sure if you need an integer, you're getting an integer, for example.
-m |
getting lost doh! sorry to keep bugging you, do i still have all the same stuff as for the whole table but then when it gets to the "while" thats where i have to change yes? how do i tell the table to return whats lower or higher than the $_POST[price]
<?php $conn = pg_connect("host=database.dcs.aber.ac.uk port=5432 dbname=teaching user=csguest password=rohishe"); $conn = pg_connect("host=database.dcs.aber.ac.uk port=5432 dbname=teaching user=csguest password=******"); $res = pg_query ($conn, "select * from TopGames"); echo "<table border='1'>"; while ($a = pg_fetch_row($res)) { echo "<tr>"; for ($j = 0; $j < pg_num_fields($res); $j++) { echo "<td>" . $a[$j] . "</td>"; } echo "</tr>";} echo "</table>\n";?> |
so ive got this far
ok so ive got this far but its not quite right can anyone help its displaying all sorts of prices
PHP Code:
|
| All times are GMT. The time now is 10:00 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0