Albatross Posted July 21, 2007 Share Posted July 21, 2007 Mornin everyone....perhaps it's because it's 730 and perhaps it's because my mindset isn't aligned yet due to lack of caffiene.... I'm trying to add a couple features to a site but having little to no luck here... On 2 dates, I need a certain area of my site open at specific times, but at any other time, I need the user directed to a 'sorry we're closed' page. But also, I have a form that when the user fills it out and hits submit, a 10 digit number is generated and both fed to the form and sent to the db as well as returned to the user. Right now, I have the form going to the db and a confirmation of everything they enetered but I also need this number, which will not exist until they hit submit, to be added. Any ideas? Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 21, 2007 Share Posted July 21, 2007 #1 - determine the time. php will generate server time so you may need to adjust that for any offset between time where you are and time where your server is. Then have conditional code like: if now<we're open AND now>we're closed show me the closed page [header() function] #2 - not sure what you mean by "I also need this number ... to be added". Added to what? And why can't create it before you write to the db and/or echo it back to the screen for the user. Quote Link to comment Share on other sites More sharing options...
Albatross Posted July 21, 2007 Author Share Posted July 21, 2007 The number I can get, it's that I don't want the user to see it until they submit the form to the db. It's placing that number in the db at the same time that the confirmation is echo'd back to the user that I can't get to work. Everything else uses a form element but the random number is a function. ex. <input type="text" name="fname"> This is for the first name and the 'fname' title I'm able to grab but this: <?php echo rand(1000000000, 9999999999); ?> Is what I'm having the issue with. I can get it to spit something out but not write itself to the record on the db. Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 21, 2007 Share Posted July 21, 2007 fill in form, hit submit process form inputs generate random number write form results and random number to database I don't see the problem yet. Quote Link to comment Share on other sites More sharing options...
Albatross Posted July 21, 2007 Author Share Posted July 21, 2007 I think the problem here is I don't know which question to ask to get the naswer i need.... the random number that I generate I don't know how to get it to write to the db is my problem. Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 21, 2007 Share Posted July 21, 2007 If you want to write it to the database, then you already have a column (field) for it, right? Just add the necessary stuff to your database INSERT query. Show a bit of the form data processing code and we'll go from there. Quote Link to comment Share on other sites More sharing options...
Albatross Posted July 21, 2007 Author Share Posted July 21, 2007 Sorry for the delay, had a couple errors I needed to squish first. The epassid field is in the db and it's shown here, I have the code to generate the id, but not to stick it into the field and this is where I'm running into trouble. <?php include ("db.php"); $sql = "INSERT INTO $table_name (q1, q2, q3, q4, q5, epassid) VALUES ('$_POST[q1]', '$_POST[q2]', '$_POST[q3]', '$_POST[q4]', '$_POST[q5]', '$_POST[epassid]')"; $result = @mysql_query($sql, $connection) or die(mysql_error()); $inputfield07=@($_POST['q1']); $inputfield08=@($_POST['q2']); $inputfield09=@($_POST['q3']); $inputfield10=@($_POST['q4']); $inputfield11=@($_POST['q5']); $inputfield12=@($_POST['epassid']); echo(mysql_error()); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>FatMan™ Inc</title> <style type="text/css"> <!-- body { background-image: url(cvgbg.gif); } body,td,th { color: #0000CC; font-size: 18px; } .style5 {font-size: 14px; font-weight: bold; } --> </style></head> <body> <table width="33%" border="0" align="left"> <tr> <td width="50%"><span class="style5">Name </span></td> <td width="50%"><? echo "$_POST[fname]"; ?> <? echo "$_POST[lname]"; ?></td> </tr> <tr> <td><span class="style5">Email Address </span></td> <td><? echo "$_POST[email]"; ?></td> </tr> <tr> <td><span class="style5">E-Pass ID</span></td> <td><? echo "$_POST[epassid]"; ?></td> </tr> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
Aureole Posted July 21, 2007 Share Posted July 21, 2007 From just taking a quick look at your code there isn't a php start tag at the top. ??? Quote Link to comment Share on other sites More sharing options...
Albatross Posted July 21, 2007 Author Share Posted July 21, 2007 Sorry, had snipped it off, fixed. Quote Link to comment Share on other sites More sharing options...
Albatross Posted July 21, 2007 Author Share Posted July 21, 2007 On my main form, I'm trying this to get the 'epassid' portion. Still not working though... <input name="epassid" type="hidden" value="<?php echo rand(1000000000, 9999999999); ?>"> Quote Link to comment Share on other sites More sharing options...
Albatross Posted July 21, 2007 Author Share Posted July 21, 2007 In my last post, I had the right idea but had made an error.....in the generate script, I had it labeled as '$_POST[$epassid]' and the $ was what was blocking it. Thank you for the help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.