This used to post data to mysql database: <form name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>"> Now the data does not post. Am I doing something wrong, or is this a server issue? How do I correct this?

When I use the code I get this error:

The requested URL /events_code/action=/events_code/book_slots.php was not found on this server.

Send the full Code))

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Events</title>
<style type="text/css">
<!--
body {
	background-color: #1CA4E2;
}

-->
</style></head>

<body>
<form name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>">

<table width="747" border="3" align="center" bordercolor="#F88712" bgcolor="#F88712">
  <tr>
    <td align="center" valign="bottom" bgcolor="#17A9D8"><p><img src="../images/header.gif" width="747" height="288" align="texttop" /></p>
      <p><br />      
      <p>      
      <p>
  
	        
      <p>      
      <p><br />
	  
	  <table width="174" border="1" align="center" bgcolor="#CCCCCC">
      <tr>
        <td width="168" align="center" valign="middle" bgcolor="#8CD0EE"><u><a href="events_home.php" class="style22">List All  Events</a></u></td>
      </tr>
    </table>
      <p><br />
        <br />
      </p>
     <?php echo "<table width='376' border='1' bordercolor='#996666' bgcolor='#CCCCCC'>
             <tr>
               <td height='28' align='left'>First Name<span class='style17'> *</span></td>
<td height='28' align='left'><input name='firstname' type='text' id='firstname' value='".$_POST['firstname']."' size='32' />
                   <input name='hidden_sid' type='hidden' id='hidden_sid' value='".$_REQUEST['sid']."' /></td>
             </tr>
             <tr>
               <td height='28' align='left'>Last Name<span class='style17'> *</span></td>
               <td height='28' align='left'><input name='lastname' type='text' id='lastname' value='".$_POST['lastname']."' size='32' /></td>
             </tr>
             <tr>
               <td height='28' align='left'>Phone Number</td>
               <td height='28' align='left'><input name='phone' type='text' id='phone' value='".$_POST['phone']."' size='32' /></td>
             </tr>
             <tr>
               <td width='177' height='28' align='left'>Email: <span class='style17'> *</span></td>
               <td width='278'><input name='email' type='text' id='email' value='".$_POST['email']."' size='32' /></td>
             </tr>
             <tr>
               <td height='28' colspan='2' align='center'><input name='register' type='submit' class='blueb' value='Register'/></td>
             </tr>
           </table>";
		   ?></span></p>
      <p>
        <?php 
require_once('db.php');
include('functions.php');
require_once("class.phpmailer.php");
$firstname=ucfirst($_POST['firstname']);
$lastname=ucfirst($_POST['lastname']);
$email=$_POST['email'];
$phone=$_POST['phone'];
$slot_id=$_POST['sid'];

if(isset($_POST['register']))
{
unset($_POST['register']);
$slot_id=$_POST['hidden_sid'];

$res_getslot=mysql_query("select * from events_slots where Slot_Id='".$slot_id."'");
$row_slot=mysql_fetch_assoc($res_getslot);
$slot_start=$row_slot['SlotStart'];
$slot_end=$row_slot['SlotEnd'];
$token_count=$row_slot['TokenCount'];
$templ_id=$row_slot['Template_Id'];
$event_id=$row_slot['Event_Id'];

if($firstname=='') {echo "Please give a Firstname"; exit();}
if($lastname=='') {echo "Please give a Lastname"; exit();}
if(!valid_email($email)) {echo "Please give a valid Email!"; exit();}

$token_count--;
$res_bookslot=mysql_query("UPDATE events_slots SET `TokenCount`= '".$token_count."' where `Slot_Id`= '".$slot_id."'") 
				or die(mysql_error()." at line 469");
		
$res_newtoken=mysql_query("INSERT into slots_tokens (`Slot_Id`,`Event_Id`,`Template_Id`,`Firstname`,`Lastname`,`Email`, `Phone`
) values( '".$slot_id."','".$event_id."','".$templ_id."',
		'".mysql_real_escape_string($firstname)."','".mysql_real_escape_string($lastname)."',
			'".mysql_real_escape_string($email)."','".$phone."')");

/* 				$headers = 	'From: [email]angela@workplacespa.com[/email]' . "\r\n" .
	    					'Reply-To: [email]angela@workplacespa.com[/email]' . "\r\n" .
	    					'X-Mailer: PHP/' . phpversion();
				$subject = "Thank you for your choice!";
				$message = "Dear $firstname, \n\n This is to confirm your Appointment. Below are your Appointment Details. Please print a copy for your records.\n\n Your Spa Date :".date("D, M j, Y",break_time($slot_start,"d"))." \n Your Spa Begins at  ".date("g:i a T",break_time($slot_start,"t"))."\n Your Spa Ends at ".date("g:i a T",break_time($slot_end,"t"))."\n We hope you have a Wonderful Experience.\n\n Angela \n\n\n P.S. Please retain this Email till you attend the Spa. If you want to cancel your Booking Please click on the link below. \n http://www.workplacespa.com/cancel_slot.php?tid=".$token_id."";

				if(mail($email, $subject, $message, $headers))
 */
  			$mail = new PHPMailer();
			$mail->ContentType="text/html";
			$mail->From ="angela@workplacespa.com" ;
			$mail->Sender="angela@workplacespa.com";
			$mail->FromName = "Work Place Spa";
			$mail->Mailer   = "mail";
			$mail->Subject = stripslashes("$firstname Let's get ready to Spa!");
			$to_mailtext= "Dear $firstname,<br><br>This is to confirm your Appointment. Below are your Appointment Details. Please 	print a copy for your records.<br><br>
			 Your Spa Date :".date("D, M j, Y",break_time($slot_start,"d"))."<br>
			 Your Spa Begins at ".date("g:i a T",break_time($slot_start,"t"))."<br>
			 Your Spa Ends at ".date("g:i a T",break_time($slot_end,"t"))."<br>
			 We hope you have a Wonderful Experience.<br><br>Workplace SPA<br><br>
			 P.S. If you need to Reschedule Please call 816-522-8582 and ask to speak with Angela";
			$mail->Body =stripslashes($to_mailtext);
			$mail->ClearAddresses();
			$mail->AddAddress($email,$firstname);
			if($mail->Send())
			{echo "<p class='style24'>Your Spa has been confirmed. Please check your Email for Details.</p>";}
}			
?>

   
            </p></td>
        </tr>
      </table>
      <p>&nbsp;</p></td>
  </tr>
  <tr>
    <td height="18" colspan="2" valign="top" bgcolor="#EFF6FC"><div class="MSC_FooterFrame"> <span id="IWS_WH_Elem_FooterLinks"> </span>
          <div id="IWS_WH_Elem_FooterText" class="MSC_FooterText"> All Rights Reserved </div>
    </div></td>
    </tr>
</table>

  <tbody>
     <tr>
       <td width="787" align="center" valign="top"><p class="style21"></td>
     </tr>
  </tbody>
</table></p>
    <p>&nbsp; </p>
    <table border="0" width="100%" cellspacing="0" cellpadding="0">
              <tr>
                <th scope="col">&nbsp;</th>
              </tr>
              <tr>
                <td width="100%" class="bluea border-left" height="54"><div align="center"><span class="style6">200 NE Missouri Road, Suite 200<br>
                  Lee's Summit, MO  64086   (816) 251-4551</span></div></td>
              </tr>
    </table></p></td>
  </tr>
</table>
</form>
</body>
</html>

Try this One

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Events</title>
<style type="text/css">
<!--
body {
background-color: #1CA4E2;
}

-->
</style></head>

<body>



<?php
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$phone=$_POST['phone'];
$eamil=$_POST['email'];
$id=$_REQUEST['sid'];
?>
<form name="form1" method="post" action="<?php echo$_SERVER['PHP_SELF']?>">

<table width="747" border="3" align="center" bordercolor="#F88712" bgcolor="#F88712">
<tr>
<td align="center" valign="bottom" bgcolor="#17A9D8"><p><img src="../images/header.gif" width="747" height="288" align="texttop" /></p>
<p><br />
<p>
<p>
<p>
<p><br />

<table width="174" border="1" align="center" bgcolor="#CCCCCC">
<tr>
<td width="168" align="center" valign="middle" bgcolor="#8CD0EE"><u><a href="events_home.php" class="style22">List All Events</a></u></td>
</tr>
</table>
<p><br />
<br />
</p>
<table width='376' border='1' bordercolor='#996666' bgcolor='#CCCCCC'>
<tr>

<td height='28' align='left'>First Name<span class='style17'> *</span></td>
<td height='28' align='left'><input name='firstname' type='text' id='firstname' value="<?php echo$firstname ?>"size='32' />
<input name='hidden_sid' type='hidden' id='hidden_sid' value="<?php echo$id ?>" /></td>
</tr>
<tr>
<td height='28' align='left'>Last Name<span class='style17'> *</span></td>
<td height='28' align='left'><input name='lastname' type='text' id='lastname' value="<?php echo$lastname ?>" size='32' /></td>
</tr>
<tr>
<td height='28' align='left'>Phone Number</td>
<td height='28' align='left'><input name='phone' type='text' id='phone' value="<?php echo$phone ?>" size='32' /></td>
</tr>
<tr>
<td width='177' height='28' align='left'>Email: <span class='style17'> *</span></td>
<td width='278'><input name='email' type='text' id='email' value="<?php echo$eamil ?>" size='32' /></td>
</tr>
<tr>
<td height='28' colspan='2' align='center'><input name='register' type='submit' class='blueb' value='Register'/></td>
</tr>
</table>
</form>
</span></p>
<p>
<?php
require_once('db.php');
include('functions.php');
require_once("class.phpmailer.php");
$firstname=ucfirst($_POST['firstname']);
$lastname=ucfirst($_POST['lastname']);
$email=$_POST['email'];
$phone=$_POST['phone'];
$slot_id=$_POST['sid'];

if(isset($_POST['register']))
{
unset($_POST['register']);
$slot_id=$_POST['hidden_sid'];

$res_getslot=mysql_query("select * from events_slots where Slot_Id='".$slot_id."'");
$row_slot=mysql_fetch_assoc($res_getslot);
$slot_start=$row_slot['SlotStart'];
$slot_end=$row_slot['SlotEnd'];
$token_count=$row_slot['TokenCount'];
$templ_id=$row_slot['Template_Id'];
$event_id=$row_slot['Event_Id'];

if($firstname=='') {echo "Please give a Firstname"; exit();}
if($lastname=='') {echo "Please give a Lastname"; exit();}
if(!valid_email($email)) {echo "Please give a valid Email!"; exit();}

$token_count--;
$res_bookslot=mysql_query("UPDATE events_slots SET `TokenCount`= '".$token_count."' where `Slot_Id`= '".$slot_id."'")
or die(mysql_error()." at line 469");

$res_newtoken=mysql_query("INSERT into slots_tokens (`Slot_Id`,`Event_Id`,`Template_Id`,`Firstname`,`Lastname`,`Email`, `Phone`
) values( '".$slot_id."','".$event_id."','".$templ_id."',
'".mysql_real_escape_string($firstname)."','".mysql_real_escape_string($lastname)."',
'".mysql_real_escape_string($email)."','".$phone."')");

/* $headers = 'From: angela@workplacespa.com' . "\r\n" .
'Reply-To: angela@workplacespa.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$subject = "Thank you for your choice!";
$message = "Dear $firstname, \n\n This is to confirm your Appointment. Below are your Appointment Details. Please print a copy for your records.\n\n Your Spa Date :".date("D, M j, Y",break_time($slot_start,"d"))." \n Your Spa Begins at ".date("g:i a T",break_time($slot_start,"t"))."\n Your Spa Ends at ".date("g:i a T",break_time($slot_end,"t"))."\n We hope you have a Wonderful Experience.\n\n Angela \n\n\n P.S. Please retain this Email till you attend the Spa. If you want to cancel your Booking Please click on the link below. \n http://www.workplacespa.com/cancel_slot.php?tid=".$token_id."";

if(mail($email, $subject, $message, $headers))
*/
$mail = new PHPMailer();
$mail->ContentType="text/html";
$mail->From ="angela@workplacespa.com" ;
$mail->Sender="angela@workplacespa.com";
$mail->FromName = "Work Place Spa";
$mail->Mailer = "mail";
$mail->Subject = stripslashes("$firstname Let's get ready to Spa!");
$to_mailtext= "Dear $firstname,<br><br>This is to confirm your Appointment. Below are your Appointment Details. Please print a copy for your records.<br><br>
Your Spa Date :".date("D, M j, Y",break_time($slot_start,"d"))."<br>
Your Spa Begins at ".date("g:i a T",break_time($slot_start,"t"))."<br>
Your Spa Ends at ".date("g:i a T",break_time($slot_end,"t"))."<br>
We hope you have a Wonderful Experience.<br><br>Workplace SPA<br><br>
P.S. If you need to Reschedule Please call 816-522-8582 and ask to speak with Angela";
$mail->Body =stripslashes($to_mailtext);
$mail->ClearAddresses();
$mail->AddAddress($email,$firstname);
if($mail->Send())
{echo "<p class='style24'>Your Spa has been confirmed. Please check your Email for Details.</p>";}
}
?>


</p></td>
</tr>
</table>
<p>&nbsp;</p></td>
</tr>
<tr>
<td height="18" colspan="2" valign="top" bgcolor="#EFF6FC"><div class="MSC_FooterFrame"> <span id="IWS_WH_Elem_FooterLinks"> </span>
<div id="IWS_WH_Elem_FooterText" class="MSC_FooterText"> All Rights Reserved </div>
</div></td>
</tr>
</table>

<tbody>
<tr>
<td width="787" align="center" valign="top"><p class="style21"></td>
</tr>
</tbody>
</table></p>
<p>&nbsp; </p>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<th scope="col">&nbsp;</th>
</tr>
<tr>
<td width="100%" class="bluea border-left" height="54"><div align="center"><span class="style6">200 NE Missouri Road, Suite 200<br>
Lee's Summit, MO 64086 (816) 251-4551</span></div></td>
</tr>
</table></p></td>
</tr>
</table>
</body>
</html>

I got it! Thanks for all your help Mr. Niceguy and Noel the fish. I am new to this so I really appreciate you. I know I will have more questions. Let me know what I can do to help you in the future.

Goodno!

//REMOVED BY ME


//Sorry saw the last message saying that it's fixed. Two bottles of wine later and I think I'm Mr. Code. Bon Voyage.

This used to post data to mysql database: <form name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>"> Now the data does not post. Am I doing something wrong, or is this a server issue? How do I correct this?

Hi you should put <input > tag within the form tag and give it a name

example

<form method="post">
 FULL NAME <input type="text" name="username" >
</form>

then put post it like it $_POST into the Database table
example if you have already created the database and the table ,lets say table name "users";

then use a query to insert the data into the database

$con=mysql_connect("localhosts","username","password");
mysql_select_db("database1",$con);
mysql_query("INSERT INTO users VALUES('$_POST[username]')",$con);

that is a simple example to post a data into table in mysql database

This article has been dead for over six months. Start a new discussion instead.