• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

Coding, Why?!

why are you making the contact form more complicated than it needs to be? no reason to use sql unless you are planning on storing all messages there, and if so, why? you can just have them sent to your email. if you are going to just email it, then use the php mail() function

mail('youemail@domain.com','SUBJECT','MESSAGE','HEADERS');

you would make the form with stuff like...

Code:
<input type=text value='.$message.' name=message />
<input type=submit value submit />
and then your code would need to change accordingly to something like...

mail('youemail@domain.com','SUBJECT',$message,'HEADERS');

so, you dont need sessions, or a databse for a simple form. if you are trying to make something more complex, explain exactly what you are looking for so we can help with what you actually need.
 
Sorry to double post, this is the contact.php coding:
PHP:
<?php session_start();
$ses_id = session_id();        // DO NOT REMOVE THIS LINE!
$_SESSION['ses_id'] = $ses_id;    // OR THIS ONE!
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <meta name="keywords" content="" />
    <meta name="description" content="" />

    <title>Contact Form</title>

<style type="text/css">
body {
    margin: 0px;
    padding: 100px;
    background: #fafafa;
    font-family: verdana, Arial, sans-serif;
    font-size: 11px;
    line-height: 18px;
}

#Wrapper {
    margin: 0 auto;
    padding: 10px;
    width: 500px;
    background: #fff;
    border: 1px solid #999999;
}

fieldset {
    margin: 0px;
    padding: 0px;
    border: 0px;
}

legend {
    display: none;
}

input, textarea {
    margin: 0px;
    padding: 1px;
    font-family: Courier, monospace;
    font-size: 11px;
    border: 1px solid #999999;
}

span.cursor {
    cursor: pointer;
}

p#Error_msg {
    color: red;
}
</style>
</head>
<body>

<div id="Wrapper">
<?php
$Error = $_GET['error'];
if(isset($Error)) {
echo '<fieldset><legend>Contact Form</legend>'."n";
echo '<form action="thank_you.php" method="post">'."n";
echo '<p><label for="name"><strong>Name :</strong></label><br />'."n";
echo '<input type="text" name="name" id="name" tabindex="1" size="40" value="'.$_SESSION['name'].'" /></p>'."nn";

echo '<p><label for="email"><strong>E-mail address :</strong></label><br />'."nn";
echo '<input type="text" name="email" id="email" tabindex="2" size="40" value="'.$_SESSION['email'].'" /></p>'."nn";

echo '<p><label for="comment"><strong>Questions / Comments :</strong></label> (<span class="cursor" onclick="document.getElementById('comment\').rows += 5;" title="Increase The Textarea">increase</span> » <span class="cursor" onclick="document.getElementById('comment').rows -= 5;" title="Decrease The Textarea">decrease</span>)<br />'."n";
echo '<textarea cols="50" rows="5" name="comment" id="comment" tabindex="3">'.$_SESSION['comment'].'</textarea></p>'."nn";

echo '<p id="Error_msg">'.$_SESSION['errormsg'].'</p>'."nn";

echo '<p><input type="submit" name="submit" value="submit" class="submit" tabindex="4" /> <input type="reset" value="reset" class="submit" tabindex="5" /></p>'."n";
echo '</form>'."n";
echo '</fieldset>'."n";
} else {
?>
<fieldset><legend>Contact Form</legend>
<form action="thank_you.php" method="post">
<p><label for="name"><strong>Name :</strong></label><br />
<input type="text" name="name" id="name" tabindex="1" size="40" /></p>

<p><label for="email"><strong>E-mail address :</strong></label><br />
<input type="text" name="email" id="email" tabindex="2" size="40" /></p>

<p><label for="comment"><strong>Questions / Comments :</strong></label> (<span class="cursor" onclick="document.getElementById('comment').rows += 5;" title="Increase The Textarea">increase</span> » <span class="cursor" onclick="document.getElementById('comment').rows -= 5;" title="Decrease The Textarea">decrease</span>)<br />
<textarea cols="50" rows="5" name="comment" id="comment" tabindex="3"></textarea></p>

<p><input type="submit" name="submit" value="submit" class="submit" tabindex="4" /> <input type="reset" value="reset" class="submit" tabindex="5" /></p>
</form>
</fieldset>
<?php } ?>
</div>

</body>
</html>

And on line 73 there's an error:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/adzwebh/public_html/contact/contact.php on line 73
 
your code on line 73 is wrong...

onclick="document.getElementById('comment').rows += 5;"

make it...

onclick="document.getElementById(\'comment\').rows += 5;"


also, i see you using "n"
it needs to be "\n"

make your whole line 73 this...

PHP:
echo '<p><label for="comment"><strong>Questions / Comments :</strong></label> (<span class="cursor" onclick="document.getElementById(\'comment\').rows += 5;" title="Increase The Textarea">increase</span> » <span class="cursor" onclick="document.getElementById(\'comment\').rows -= 5;" title="Decrease The Textarea">decrease</span>)<br />'."n";

reason it is messed up is you are using echo '

that means when you use another ', there needs to be a . and a call to a php variable. since you arent trying to call one, and you are using js there, put a forward slash so it sees it as just a ' and not the end of the echo. hope that helps.
 
Last edited:
Thanks MCT! Worked, but I got another error now :( :
Parse error: syntax error, unexpected ')', expecting T_PAAMAYIM_NEKUDOTAYIM in /home/adzwebh/public_html/contact/config.php on line 22

PHP:
<?php

function SafeHTML($strong){
$string = stripslashed($strong);
$string = htmlspecialchars($strong);
return nl2br($string);
}

/*
The function 'SafeHTML' helps to protect you from being sent HTML emails via the contact form.

http://us2.php.net/manual/en/function.htmlspecialchars.php

*&(ampersand) becomes &
*"(double quote) becomes "
*'(single quote) becomes '
*<(less than) becomes <
*>(greater than) becomes >
*/

function ValidateEmail($Email){
$result = ereg("^[^@]+@[^@]+.[^@.]+$",&Email);
if ($result){
return true;
} else {
return false;
}
}

/*
The 'ValidateEmail' function checks to see if the email provided is that of the structure of a real email address (something@somewhere.com). It doesnt check if the email address is a REAL address ... it just checks the format.
*/

$ErrorDomain = "http://adz.webhost-warehouse.com/contact/contact.php?error=1";

/*
The '$ErrorDomain' variable stores the URL the browser should redirect to should any errors be encountered. Whatever you change the URL to, make sure you keep '?error=1' at the end.
*/

$to = "Test<me@adzp.co.uk>";
$subject = "Contact Form";

/*
'$to' is your email address, where the form shall be sent to.
'$subect' is the subject of the email.
*/

?>

^thats the config.php file, and the error is on thank_you.php
http://www.adz.webhost-warehouse.com/contact/thank_you.php
 
change

PHP:
$result = ereg("^[^@]+@[^@]+.[^@.]+$",&Email);

to

PHP:
$result = ereg("^[^@]+@[^@]+.[^@.]+$",$Email);
 
Back
Top