
dh526
Members-
Posts
39 -
Joined
-
Last visited
Never
Everything posted by dh526
-
also : echo $name; echo $num; echo $type; echo $ex; echo $sec; echo $username; writes exactly what I want it too :s
-
Hi everyone, just as I thought I was getting the hang of this something has baffled me :S I have an Access database, with several tables in it. Some of these are tblAddress and tblCard. Now, I copied and pasted the code from tblAddress 's php file to tblCard 's... obviously I changed all the names and double checked etc... These are the 2 files for tblCard: card.php <form action="addcard.php" method="POST"> <table border = 0> <tr> <td>Name on Card :</td> <td> <input type='text' name='name' /></td> </tr> <tr> <td>Number: </td> <td> <input type='text' name='num' /></td> </tr> <tr><td>Type: </td> <td> <input type='text' name='type' /></td> </tr> <tr><td>Expiry Date: </td> <td> <input type='text' name='ex' /></td> <td>Please enter in the form of MM/YY</td></tr> <tr><td>Security number: </td> <td> <input type='text' name='sec' /></td> <td>This is the 3 digit code on the signature strip</td> </tr> <tr><td> </td></tr> <tr><td> <input type='submit' value='Add Card'></td> <td> </td></tr> </form> </table> and addcard.php <?php $name= $_POST['name']; $num= $_POST['num']; $type= $_POST['type']; $ex= $_POST['ex']; $sec= $_POST['sec']; $conn=odbc_connect('db09','',''); $sql="INSERT INTO tblCard (username, name, type, number, exp, sec) VALUES ('$username', '$name', '$type', '$num', '$ex', '$sec')"; if (odbc_exec($conn,$sql)) { echo "Thank you for registering a Card!"; } else { echo "Unfortunately there has been a problem - please <a href='card.php'>Try again</a>"; echo $name; echo $num; echo $type; echo $ex; echo $sec; echo $username; } odbc_close($conn); ?> I just dont see when I can possibly be going wrong, but it must be something simple :S I have checked and checked and checked to make sure my field names are right both from the form and from the database... Also $username is stored in a cookie and works completely in all of my other pages.. Arggghhh, help me !!
-
<?php if (isset($_COOKIE['username'])) { echo "<a href='signedin.php'>$username</a>"; } else { echo "<a href='login.html'>login</a>"; } ?> Better lol Thanks a lot dude
-
Thanks man It works now How do I set this to resolved?
-
So would something like this work: <?php if (isset($_COOKIE['username'])) { echo "<a href='signedin.php'>$username</a>"; } else { echo "<a href='login.html'>login</a>"; } ; ?> Ps. I'm unsure if i got the ;'s in the right place...
-
hi everyone and thank you for looking I have a login system where you enter a username and password, then if they are correct you are signed in. There is a Cookie called 'username' which holds the username from the sign in field. Is it possible to do something like this : If Cookie is set then echo "<a href='usersignedin.php'>$username</a>; else echo "<a href='login.php'>Login</a> Thank you for you help Any help would be much appreciated:)
-
Firstly, thank you for looking ! Now for the question, is it possible to enter details from a form into 2 Access tables at once? This is the sort of thing I want to do : <form method="post" action="register.php"> <table border = 0> <tr> <td>Username: </td> <td> <input type="text" name="username" /></td> <td> Please choose a unique username </td> </tr> <tr> <td>Forename: </td> <td> <input type="text" name="forename" /></td> </tr> <tr> <td>Surname: </td> <td> <input type="text" name="surname" /> </td> </tr> <tr> <td>DOB: </td> <td> <input type="text" name="dob" /> </td> <td>Please enter in the form of dd/mm/yyyy</td> </tr> <tr> <td>Email: </td> <td> <input type="text" name="email" /> </td> </tr> <tr> <td><br></td> </tr> <tr> <td>House Number: </td> <td> <input type="text" name="housenumber" /> </td> </tr> <tr> <td>Street: </td> <td> <input type="text" name="street" /> </td> </tr> <tr> <td>Town: </td> <td> <input type="text" name="town" /> </td> </tr> <tr> <td>Postcode: </td> <td> <input type="text" name="postcode" /> </td><td> enter in the form of LL99 9LL </td> </tr> <tr> <td> <input type="submit"></td> <td> </td> </tr> </form> </table> and the php file: <?php $username= $_POST ['username']; $surname = $_POST ['surname']; $forename = $_POST ['forename']; $dob = $_POST ['dob']; $email = $_POST ['email']; $housenumber = $_POST ['housenumber']; $street = $_POST ['street']; $town = $_POST ['town']; $postcode = $_POST ['postcode']; $conn=odbc_connect('db09','',''); $sql="INSERT INTO tblCustomer (username, Surname, Forename, DOB, [Email Address]) VALUES ('$username', '$surname','$forename', '$dob','$email')"; $sql2="INSERT INTO tblAddress (username, HouseNumber, Street, Town, Postcode) VALUES ('$username', '$housenumber','$street', '$town','$postcode')"; if (odbc_exec($conn,$sql,$sql2)) { echo "Welcome, Your records have been added to our system"; } odbc_close($conn); ?> Is this possible?? Or not? Thank you for looking
-
Nope, this still doesn't work
-
Sorry for starting another thread but I still was a bit confused :S Here is the problem, I just want to create a (very) simple login system. Any help would be much appreciated I have login.html <html> <head> </head> <body> Please login <br> <form method="post" action="login1.php"> username:<input type="text" name= "username"/> <br> <input type="submit" /> </form> </body> </html> and login1.php <html> <head> </head> <body> <? $username = $_POST ['username']; setcookie('username', $username); echo "<a href="login2.php">LINK</a>"; ?> </body> </html> and then i want to show the username in another page, called login2.php <? echo $_COOKIE['username']; ?> again, I don't know why this isn't working :S I feel like it makes sense :S Sorry, I feel such a plonker while doing this sometimes ...
-
Thank you Still not 100% done though... I have login.html <html> <head> </head> <body> Please login <br> <form method="post" action="login1.php"> username:<input type="text" name= "username"/> <br> <input type="submit" /> </form> </body> </html> and login1.php <html> <head> </head> <body> <? $username = $_POST ['username']; setcookie('username', $username); echo "<a href="login2.php">LINK</a>"; ?> </body> </html> and then i want to show the username in another page, called login2.php <? echo $_COOKIE['username']; ?> again, I don't know why this isn't working :S Sorry, I feel such a plonker while doing this sometimes ...
-
Right, this is my second message on here because I'm a beginner to php. It is very interesting though and last time people were VERY helpful This might be a very basic question but I'm not sure quite where I'm going wrong even though I kind of know it will be something silly I am doing wrong :S This question relates to cookies... I know how to set a cookie, with setcookie('username', $username) however I do not know how to set $username to be a value that is input by the user into a form. I am creating a login system for a website and this will make everything else fall into place (i hope) so any help would be much appreciated:) So i want to do something like this: User enters name into a text field in a form called 'username' the value of 'username' is stored in the cookie. then in another page this can be accessed and printed Thank you so so much for your help
-
Thank you!! It works !! And I'll use and in future thanks again
-
Thank you for the response, but it still doesn't work I have tried quotes and no quotes every where... Any other ideas?
-
Hi, First of all, I'd like to say I'm new to PHP but I'm enjoying it a lot I've been doing it at uni so far but tried to set it up on my web server at home. I have a working install of PHP and I can connect to my database using a DSN (called db09) which allows me to read data from a very simple table in the database. However, the problems arise when I try to use INSERT INTO to insert data into the database from a form. Here is my code : --- THIS WORKS --- <html> <head> <title>PHP Database 1</title> </head> <body> <H1>PHP Example: Select all data from a database</H1> <?php $DSN="db09"; $conn= odbc_connect('db09','',''); $sql="Select * from tblCustomer"; $rs=odbc_exec($conn,$sql); echo ("<p>Customers details:"); echo ("<table border='1'>"); While (odbc_fetch_row($rs)) { $Surname=odbc_result($rs,"Surname"); echo ("<tr><td>Name:</td><td>$Surname</td>"); } odbc_close($conn); ?> </body> </html> ----------------------- THIS DOESN'T WORK - FORM. ------------------------- <html> <head> </head> <body> <p>Input a new customer record</p> <form method="post" action="register.php"> <p>Surname: <input type="text" name="surname" /> </p> <p>Forename: <input type="text" name="forename" /></p> <p>DOB: <input type="text" name="dob" /> </p> <p>Email: <input type="text" name="email" /> </p> <input type="submit"> </form> </body> </html> --------------------- AND HERE IS THE PHP ------------------- <html> <head> </head> <body> <?php $surname = $_POST ['surname']; $forename = $_POST ['forename']; $dob = $_POST ['dob']; $email = $_POST ['email']; $conn=odbc_connect('db09','',''); $sql="INSERT INTO "tblCustomer" ("Surname", "Forename", "DOB", "Email Address") VALUES ($surname','$forename', '$dob','$email')"; if (odbc_exec($conn,$sql)) { echo "Record added"; } odbc_close($conn); ?> </body> ------------------- And the table name and the field names are right ... I checked them lots any help would be much appriciated Thank you David Harrison