blesseld Posted January 28, 2009 Share Posted January 28, 2009 I'm almost giving up...I have no idea what to ...here's where I got before HTML <?php $uname = $_POST['uname']; $idnumber = $_POST['idnumber']; $self = $_SERVER['PHP_SELF']; if( ( $uname != null ) and ( $idnumber != null ) ) { setcookie( "username", $uname , time() + 86400 ); // 24 hours setcookie( "identnumber", $idnumber, time() + 86400 ); } elseif (isset($_COOKIE['username'])) { $user = $_COOKIE['username']; $color= $_COOKIE['identnumber']; } else { $user = $_POST['uname']; $color = $_POST['idnumber']; } ?> form <form method="post" action="freeform_a.php"> Your Name: <input name="uname" type="text" size="20" maxlength="20" value="<?php echo( $uname ); ?>" /><br /> Your ID: <input name="idnumber" type="text" size="20" maxlength="6" value="<?php echo( $idnumber ); ?>" /><br /> <input type="submit" value="Add Me!"/> </form> Action page <?php $con = mysql_connect("localhost","justadz_form","form1"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("justadz_testmail", $con); $sql="INSERT INTO freeFormTable (ID, uname, idnumber) VALUES ('NULL','$_POST[uname]','$_POST[idnumber]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } else header( "Location: http://freeaisle.com/?page_id=6" ); //Location is my thankyou page mysql_close($con) ?> I just want to get the cookie to save and then fill in the form for me...just to get something to work..but what i ultimatly need is if the user has already submitted, and a cookie has been created , I don't want them to see the form..somthing with includes maybe... But for now I just want to see the cookies workign...please help Link to comment https://forums.phpfreaks.com/topic/142738-help-setting-cookie-from-form/ Share on other sites More sharing options...
gevans Posted January 28, 2009 Share Posted January 28, 2009 Try using a session. Cookies require a page refresh before registering as they're sent out with the page headers Link to comment https://forums.phpfreaks.com/topic/142738-help-setting-cookie-from-form/#findComment-748320 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.