Jump to content

[SOLVED] 2 things...possibly small


Albatross

Recommended Posts

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?

Link to comment
Share on other sites

#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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.