problem with contact us page.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
brandond
Forum Newbie
Posts: 4
Joined: Wed Mar 19, 2008 11:26 pm

problem with contact us page.

Post 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 -->
Last edited by brandond on Wed May 28, 2008 10:49 pm, edited 2 times in total.
User avatar
freeformer
Forum Newbie
Posts: 14
Joined: Tue May 13, 2008 1:54 pm
Location: UK

Re: problem with contact us page.

Post 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
suresh_2220
Forum Newbie
Posts: 23
Joined: Mon May 12, 2008 3:13 pm

Re: problem with contact us page.

Post by suresh_2220 »

can i know the meaning of optional_param() fn?
Post Reply