Page 1 of 1

problem with contact us page.

Posted: Wed May 14, 2008 10:21 am
by brandond
I've created some code to do a simple contact us form, but for some reason, nothing displays when I run put the code up on the net. I'm extremely new to php, so I'm not sure where my issue is. I had working code, before adding the $username variable.

Code: Select all

<!-- contact form example -->
<?php
global $messages, $CFG;
 
$subject = optional_param('contact-type');
$body = optional_param('contact-body');
$from = optional_param('contact-email');
$username = optional_param('contact-username');
 
if (!empty($subject) && !empty($body) && !empty($from) && !empty($username) {
// email to info
$user = new StdClass;
$user->email = "myemail@domain.com; //CHANGE ME
 
$body = "From: $from\n\n$body";
$subject = "[Contact] $subject";
 
email_to_user($user, "Contact", $subject, $body);
 
$messages[] = __gettext('Thanks for your message.  We'll get back to you within 24 hours.');
}
 
?>
 
<h2>Contact form</h2>
 
<form action="" method="post">
 
<strong>Type:</strong>
<select name="contact-type">
<option value="Your Site Rules!">Bug report</option>
<option value="I want a job...">Bug report</option>
<option value="Feedback">Feedback</option>
<option value="Bug report">Bug report</option>
<option value="Feature Request">Bug report</option>
<option value="Account Deletion Request">Bug report</option>
</select>
<br />
 
<strong>Your email:</strong><br />
<input type="text" name="contact-email" />
<br />
 
<strong>Your username:</strong><br />
<input type="text" name="contact-username" />
<br />
 
<strong>Message</strong><br/>
<textarea name="contact-body"></textarea>
<br/>
 
<input type="submit" value="Submit" />
</form>
<!-- eof -->

Re: problem with contact us page.

Posted: Wed May 14, 2008 11:23 am
by freeformer
It's likely there's a syntax error with your script.

At the top of the page (after the opening <?php tag) use

Code: Select all

error_reporting(E_ALL);
This should then display any errors that have been made and allow you to find out what's wrong quickly

Re: problem with contact us page.

Posted: Wed May 14, 2008 11:30 am
by suresh_2220
can i know the meaning of optional_param() fn?