Hi ixalmida,
Well my last post was just resolved, it was titled "select menu".
I wouldn't go this deep since I am using a simple array and a drop-down menu, so there won't be much manipulation possible. Also I am very limited in my coding and programming ability and this looks like it is delving into mysql.
Would there be a simpler solution? Could this code:
<input type="button" name="course_name" value="Add Course"
onclick="window.location='add_course.php?course_id=1234'" />
be made to deal directly with the registration form already made with some form of modification? Here is the registration form so you can have an idea of what we're dealing with (dots in the arrays are to truncate a long list of entries):
<div class="container"> <br />
<!-- The contact form starts from here-->
<?php
$coursearray = array(
'Mngmnt & Leadership: Modern Trends in Leadership and Supervision Skills',
'Mngmnt & Leadership: Modern Trends of Hospitals Management',
.
.
.
'Acc & Finance: Reading , interpreting and analyzing financial statements',
'Acc & Finance: Management of Bad Debts'
); // you enter the options here for the courses
$datearray = array(
'06-10 September 2010',
'20-24 September 2010',
.
.
.
'25-29 July 2011'
); // you enter the options here for the dates
$error = ''; // error message
$name = ''; // sender's name
$email = ''; // sender's email address
$subject = 'Course Registration Form'; // subject
$message = ''; // the message itself
$spamcheck = ''; // Spam check
if(isset($_POST['send']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$spamcheck = $_POST['spamcheck'];
/* first we need to require our MathGuard class */
require ("ClassMathGuard.php");
/* this condition checks the user input. Don't change the condition, just the body within the curly braces */
if (MathGuard :: checkResult($_REQUEST['mathguard_answer'], $_REQUEST['mathguard_code'])) {
echo (""); //insert your code that will be executed when user enters the correct answer
} else {
$error = '<div class="errormsg">The Mathguard anti-spam number you entered is wrong. Please enter the correct answer.</div>';
}
if(trim($name) == '')
{
$error = '<div class="errormsg">Please enter your name!</div>';
}
else if(trim($email) == '')
{
$error = '<div class="errormsg">Please enter your email address!</div>';
}
else if(!isEmail($email))
{
$error = '<div class="errormsg">You have entered an invalid e-mail address. Please, try again, with a proper email address that contains the "@" sign.</div>';
}
else if(trim($subject) == '')
{
$error = '<div class="errormsg">Please enter a subject!</div>';
}
else if($error == '')
{
if(get_magic_quotes_gpc())
{
$message = stripslashes($message);
}
// the email will be sent here
// make sure to change this to be your e-mail
$to = "md@emirates-enterprise.com, samer.helmy@gmail.com";
// the email subject
// '[Contact Form] :' will appear automatically in the subject.
// You can change it as you want
$subject = '[Emirates Enterprise] : ' . $subject;
// the mail message ( add any additional information if you want )
$msg = "From : $name \r\ne-Mail : $email \r\nSubject : $subject \r\n\n Course chosen: $coursearray[$course] \r\n\n Date: $datearray[$date]\r\n\n" . "Message : \r\n$message";
mail($to, $subject, $msg, "From: $email\r\nReply-To: $email\r\nReturn-Path: $email\r\n");
// autoresponder subject
$subject2 = 'Course Registration Confirmation: Thank you for your registration';
// autoresponder message
$msg2 = "Dear $name \r\n\nThank you for registering to attend our '$coursearray[$course]' course, booked to be attended between $datearray[$date].\r\n\nPlease wait for contact from us to process your registration\r\n";
mail($email, $subject2, $msg2, "From: $to\r\nReply-To: $to\r\nReturn-Path: $to\r\n");
?>
<!-- Message sent! (change the text below as you wish)-->
<div style="text-align:center;">
<h1>Dear <?php echo $name;?>. Thank You For Registering</h1>
<p><font size="3">Your Course Registration has been Successfully submitted. You will receive an email confirming the course details.</font></p>
<p> </p>
<p><font size="3">Please, contact us if you need anything further through the <a href="./contact.html"Contact Us</a> page, or call directly one of the phone numbers listed there.</font></p>
</div>
<!--End Message Sent-->
<?php
}
}
if(!isset($_POST['send']) || $error != '')
{
?>
<h1><center>Registration Form:</center></h1>
<p><font size="3"><font color="#FF0000">IMPORTANT:</font> Please choose the <strong>preferred date</strong> of the course you wish to attend from the date drop down menu, and confirm the course you wish to attend. Afterwards, enter your name, company, phone number (with country code) and email address in the forms below.</font></p>
<p><font size="3">Add any specific details or instructions if you wish in the message field and click submit to receive an email confirming your registration, and notifying one of our consultants to contact you.</font></p>
<p>(Fields marked with a <span class="required">*</span> are compulsory)</p>
<!--Error Message-->
<?php
echo $error;?>
<form method="post" name="regFrm" id="regFrm" action="">
<label><span class="required">*</span> Course: </label>
<select name='course' id='course'>
<?php
foreach ($coursearray as $key => $value ) {
if(isset($_POST['course']) && $key == $_POST['course']) {
echo '<option value="' . $key . '" selected> ' . $value . '</option>';
}
else {
echo '<option value="' . $key . '"> ' . $value . '</option>';
}
}
?>
</select><br />
<label><span class="required">*</span> Date:</label>
<select name='date' id='Listbox1'>
<?php
foreach ($datearray as $key => $value ) {
if(isset($_POST['date']) && $key == $_POST['date']) {
echo '<option value="' . $key . '" selected> ' . $value . '</option>';
}
else {
echo '<option value="' . $key . '"> ' . $value . '</option>';
}
}
?>
</select><br />
<label><span class="required">*</span> Full Name:</label>
<input name="name" type="text" class="box" id="name" size="30" value="<?php echo $name;?>" /><br />
<label><span class="required">*</span> Email: </label>
<input name="email" type="text" class="box" id="email" size="30" value="<?php echo $email;?>" /><br />
<label><span class="required">*</span> Subject: </label>
<input name="subject" type="text" class="box" id="subject" size="30" value="<?php echo $subject;?>" /><br />
<label>Message: </label>
<textarea name="message" cols="40" rows="3" id="message"><?php echo $message;?>
</textarea><br />
<label><span class="required">* Security Question</span></label><? require_once ("ClassMathGuard.php"); MathGuard::insertQuestion(); ?>
<br />
<br />
<!-- Submit Button-->
<input name="send" type="submit" class="button" id="send" value="" />
</form>
<!-- E-mail verification. Do not edit -->
<?php
}
function isEmail($email)
{
return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i"
,$email));
}
?>
<!-- END CONTACT FORM -->
</div>