Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 02-04-2005, 05:59 AM   PM User | #1
lellan
New to the CF scene

 
Join Date: Feb 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
lellan is an unknown quantity at this point
HELP...MySQL Timestamp Posted From Form.

If someone can help me I sure would appreciate it.

Everything in this form gets posted 100% to my database Except the DATE.

My database column is called (date) and type is set to TIMESTAMP (14)

I am new to both PHP and MySQL and have spent a week looking for this problem.

Can someone explain exactly what is wrong and why the date in the database keeps coming up as 00000000000000 and not the current Date and Time etc.?

Tks,

PS..... I have read all the PHP and MySQL manuals and still cannot seem to figure it out. Yup, I am new, but this one is driving me nuts!

Bellow is the form file I am working with called signup.php .................

PHP Code:
<?
  session_start
();
  
header("Cache-control: private"); // IE 6 Fix. 

  
include "../affconfig.php";
  include 
"./lang/$language";
  include 
"./countries.php";
  
  
$errorMsg '';
  
  if(
$_POST['commited'] == 'yes')
  {
    
// form was sent
    
mysql_connect($server$db_user$db_pass)
      or die (
"Database CONNECT Error (line 8)"); 

    if(
$_POST['ausername'] == '')
      
$errorMsg .= AFF_SI_UNAMEMISSING.'<br>'

    
// check if user doesnt exist already
    
$userid preg_replace('/[^a-zA-Z0-9_]/'''$_POST['ausername']); // protect against sql injection
    
    
$chk_user mysql_db_query($database"select refid from affiliates where refid='$userid'");
    if(
mysql_num_rows($chk_user) > 0)
    {
      
$errorMsg .= AFF_SI_USEREXISTS.'<br>'
      
$_POST['ausername'] = '';
    }
    
    if(
$_POST['apassword'] == '')
      
$errorMsg .= AFF_SI_PWDMISSING.'<br>';
      
    if(
$_POST['aemail'] == '')
      
$errorMsg .= AFF_SI_EMAILMISSING.'<br>';

    if(
$errorMsg == ''
    {
      
// save and send notification email
      
$aemailbody "Dear ".$_POST['afirstname'].",\n\nThank you for signing up to our affiliate program.\nYour account details are below:\n\n"
          
."Username: ".$_POST['ausername']."\nPassword: ".$_POST['apassword']."\n\n"
          
."You can log into your account and view your 'real-time' statistics by going to:\n"
          
."http://".$domain."/user/index.php\n\n"
          
."Thank you once again, and we wish you luck with your profit making!\n\n\n"
          
."Affiliate Manager\n"
          
.$_POST['emailinfo']."\n\n\n\n";
      
      
mysql_db_query($database"INSERT INTO affiliates VALUES ('".$_POST['ausername']."', '".$_POST['apassword']."', '".$_POST['acompany']."', '".$_POST['atitle']."', '".$_POST['afirstname']."', '".$_POST['alastname']."', '".$_POST['awebsite']."', '".$_POST['aemail']."', '".$_POST['apayable']."', '".$_POST['astreet']."', '".$_POST['atown']."', '".$_POST['acounty']."', '".$_POST['apostcode']."', '".$_POST['acountry']."', '".$_POST['aphone']."', '".$_POST['afax']."', '".$_POST['adate']."', '".$_POST['activate']."')"
        or die(
mysql_error()); 
      
      include 
"thankyou.php"
            
      
mail($_POST['aemail'], "Welcome New Affiliate!"$aemailbody"From:".$emailinfo."\nReply-To:".$emailinfo."\n"); 
      exit;
    }     
  }
  
  
  include 
"header.php"
?>
<body bgcolor="#eeeef0">
<p align=center><br>
      <p align=center><font face=Arial size=2 color=#000000><b><font size=3>Affiliate Signup</font></b></font></p>
<? if($errorMsg != '')
     echo 
"<p align=center><font color=#ff0000>$errorMsg</font></p>";
?>      
      <form name="signupform" method="post" action="signup.php">
        <table border="0" cellspacing="3" cellpadding="1">
          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">Title:</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
              <select name="atitle">
                <option value="Mr">Mr</option>
                <option value="Mrs">Mrs</option>
                <option value="Miss">Miss</option>
                <option value="Ms">Ms</option>
                <option value="Dr">Dr</option>
              </select>
              </font></b></td>
          </tr>
          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">First 
              Name:</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
              <input type="text" name="afirstname" size=20 value="<?=$_POST['afirstname']?>">
              </font></b></td>
          </tr>
          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">Last 
              Name:</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
              <input type="text" name="alastname" size=20 value="<?=$_POST['alastname']?>">
              </font></b></td>
          </tr>
          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">Company:</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
              <input type="text" name="acompany" size=20 value="<?=$_POST['acompany']?>">
              </font></b></td>
          </tr>
           <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">Website 
              Address:</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
              <input type="text" name="awebsite" size=20 value="<?=$_POST['awebsite']?>">
              </font></b></td>
          </tr>
          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">Email 
              Address: *</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
              <input type="text" name="aemail" size=20 value="<?=$_POST['aemail']?>">
              </font></b></td>
          </tr>
          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">Street 
              Address:</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
              <input type="text" name="astreet" size=20 value="<?=$_POST['astreet']?>">
              </font></b></td>
          </tr>
          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">Town:</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
              <input type="text" name="atown" size=20 value="<?=$_POST['atown']?>">
              </font></b></td>
          </tr>
          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">County/State:</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
              <input type="text" name="acounty" size=20 value="<?=$_POST['acounty']?>">
              </font></b></td>
          </tr>
          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">PostCode/Zip:</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
              <input type="text" name="apostcode" size=20 value="<?=$_POST['apostcode']?>">
              </font></b></td>
          </tr>
          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">Country:</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
             <select name=acountry class=dropdown value="UK" >
<?
            
foreach($GLOBALS['countries'] as $key => $country)
                print 
'<option value="'.$key.'" '.($_POST['acountry'] == $key 'selected' '').'>'.$country.'</option>'."\n";
?>
              </select>
              </font></b></td>
          </tr>

          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">Phone:</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
              <input type="text" name="aphone" size=20 value="<?=$_POST['aphone']?>">
              </font></b></td>
          </tr>
          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">Fax:</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
              <input type="text" name="afax" size=20 value="<?=$_POST['afax']?>">
              </font></b></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">Choose 
              Username: *</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">
              <input type="text" name="ausername" maxlength="12" size=20 value="<?=$_POST['ausername']?>">
              </font></b></td>
          </tr>
          <tr> 
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000">Choose 
              Password: *</font></b></td>
            <td><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#000000"> 
              <input type="password" name="apassword" size="20" maxlength="12" >
              
        <input type="hidden" name="adate" value="now()">          
              <input type="hidden" name="activate" value="0">
             
              </font></b></td>
          </tr>
         
          <tr> 
            <td colspan=2> 
              <p>&nbsp;</p>
            </td>
           </tr>
          <tr> 
            <td colspan="2"> 
              <div align="center"> 
                <input type=hidden name=commited value=yes>
                
          <input type="submit" value="Submit Application" name="submit" >
        </div>
            </td>
          </tr>
        </table>
      </form>
      <br>
      
<?PHP include "footer.php"?>

Last edited by lellan; 02-04-2005 at 07:03 AM..
lellan is offline   Reply With Quote
Old 02-04-2005, 06:06 AM   PM User | #2
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,435
Thanks: 2
Thanked 38 Times in 38 Posts
Brandoe85 will become famous soon enough
Is the date being entered in on the form, or are you just inserting the current date when the form is submitted?? You can use now(), which will insert the current date.
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 02-04-2005, 06:09 AM   PM User | #3
hemebond
Senior Coder

 
Join Date: Jul 2004
Location: New Zealand
Posts: 1,315
Thanks: 0
Thanked 2 Times in 2 Posts
hemebond is an unknown quantity at this point
Please edit your post and place the code with vBcode code or php tags.
PHP Code:
mysql_db_query($database"INSERT INTO affiliates VALUES ('".$_POST['ausername']."', '".$_POST['apassword']."', '".$_POST['acompany']."', '".$_POST['atitle']."', '".$_POST['afirstname']."', '".$_POST['alastname']."', '".$_POST['awebsite']."', '".$_POST['aemail']."', '".$_POST['apayable']."', '".$_POST['astreet']."', '".$_POST['atown']."', '".$_POST['acounty']."', '".$_POST['apostcode']."', '".$_POST['acountry']."', '".$_POST['aphone']."', '".$_POST['afax']."', NOW(), '".$_POST['activate']."')")
or die(
mysql_error()); 
That should do what you need.
hemebond is offline   Reply With Quote
Old 02-04-2005, 06:54 AM   PM User | #4
lellan
New to the CF scene

 
Join Date: Feb 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
lellan is an unknown quantity at this point
Solved... Thank You..!!!

Problem is Solved ...... It works perfectly! .... Thank you everyone!

Hemebond .... You had it right. I tried that now() a couple times before, but had put it in the wrong place in the code.

Everyone, I really appreciate the help.

Thank you.
lellan

Last edited by lellan; 02-04-2005 at 07:05 AM..
lellan is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:25 AM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.