Jump to content

Recommended Posts

Hello, I found some usefull code here and cant figure out what I done wrong. I am trying to produce form-mail that will email me any submitted brithday. Please help!! :D Thanks

 

This is my index.php file

 

<?php 
$monthOptions = '';
$dayOptions = '';
$yearOptions = ''; 

for($month=1; $month<=12; $month++)
{
    $monthName = date("M", mktime(0, 0, 0, $month));
$monthOptions .= "<option value=\"{$month}\">{$monthName}</option>\n";	
}
for($day=1; $day<=31; $day++)
{
    $dayOptions .= "<option value=\"{$day}\">{$day}</option>\n";
}
for($year=1996; $year<=2011; $year++)
{
$yearOptions .= "<option value=\"{$year}\">{$year}</option>\n";
}
?>
<html>
<head>
<script type="text/javascript">
function updateDays()
{
//Create variables needed    
var monthSel = document.getElementById('month');    
var daySel   = document.getElementById('day');    
var yearSel  = document.getElementById('year');    
var monthVal = monthSel.value;    
var yearVal  = yearSel.value;

//Determine the number of days in the month/year    
var daysInMonth = 31;    
if (monthVal==2)    
{
daysInMonth = (yearVal%4==0 && (yearVal%100!=0 || yearVal%400==0)) ? 29 : 28;    
}
else if (monthVal==4 || monthVal==6 || monthVal==9 || monthVal==11)    
{
	daysInMonth = 30;    
}

//Add/remove options from days select list as needed    
if(daySel.options.length > daysInMonth)
{   //Remove excess days, if needed        
	daySel.options.length = daysInMonth;    
}
while (daySel.options.length != daysInMonth)
{   //Add additional days, if needed        
	daySel.options[daySel.length] = new Option(daySel.length+1, daySel.length+1, false);    
}

return;
}

</script>
</head>
<body>
<form name="Birthday" method="post" action="post.php">
  Birthdate:
    <select name="month" id="month" onChange="updateDays();">
      <?php echo $monthOptions; ?>
    </select>
    <select name="day" id="day">
      <?php echo $dayOptions; ?>
    </select>
    <select name="year" id="year" onChange="updateDays();">
      <?php echo $yearOptions; ?>
    </select>
</form>
<div style="padding-top: 5px"><input type="submit" name="Submit" value="Submit" style="font-family: Tahoma, Geneva, sans-serif" style="font-size: 10px"></div>

</body>
</html>

 

This is my post.php file

 

<?php
// Receiving variables
@$month = addslashes($_POST['month']);
@$day = addslashes($_POST['day']);
@$year = addslashes($_POST['year']);

//Sending Email to form owner
$pfw_header = "From: VBS\n"
  . "Reply-To: VBS\n";
$pfw_subject = "VBS";
$pfw_email_to = "your@email.net";
$pfw_message = "Birthday: $month $day $year\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>fixed</font></p>");
?>

Link to comment
https://forums.phpfreaks.com/topic/238683-birthday-script/
Share on other sites

your submit button is outside of the form tag. move it inside:

</form>
<div style="padding-top: 5px"><input type="submit" name="Submit" value="Submit" style="font-family: Tahoma, Geneva, sans-serif" style="font-size: 10px"></div>

should be:

<div style="padding-top: 5px"><input type="submit" name="Submit" value="Submit" style="font-family: Tahoma, Geneva, sans-serif" style="font-size: 10px"></div>
</form>

Link to comment
https://forums.phpfreaks.com/topic/238683-birthday-script/#findComment-1226540
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.