/    Sign up×
Community /Pin to ProfileBookmark

PHP Form Script HELP??

I an using a really simple PHP script to process a contact form.

Here’s the problem I have. I want to supress the html line break characters when a user hits return in the text area comments box.

As it is now, if they hit return the email generated by the php script puts in <br />&nbsp;<br />.

Is there a way I can suppress these characters??

The PHP code I’m using is below…

Thanks!
Joseph

<?php
include(“global.inc.php”);
$errors=0;
$error=”The following errors occured while processing your form input.<ul>”;
pt_register(‘POST’,’name’);
pt_register(‘POST’,’address’);
pt_register(‘POST’,’city’);
pt_register(‘POST’,’state’);
pt_register(‘POST’,’zip’);
pt_register(‘POST’,’email’);
pt_register(‘POST’,’dob’);
pt_register(‘POST’,’homephone’);
pt_register(‘POST’,’workphone’);
pt_register(‘POST’,’comments’);
$comments=preg_replace(“/(1512)|(15)|(12)/”,”&nbsp;<br />”, $comments);pt_register(‘POST’,’details’);
if($name==”” || $email==””){
$errors=1;
$error.=”<li>You did not enter one or more of the required fields. Please go back and try again.”;
}
if($errors==1) echo $error;
else{
$where_form_is=”http”.($HTTP_SERVER_VARS[“HTTPS”]==”on”?”s”:””).”://”.$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),”/”));
$message=”Name: “.$name.”
Address: “.$address.”
City: “.$city.”
State: “.$state.”
Zip Code: “.$zip.”
Email Address: “.$email.”
Date of Birth: “.$dob.”
Home Phone #: “.$homephone.”
Work Phone #: “.$workphone.”
Comment Form: “.$comments.”
Radial Button Selection: “.$details.”
“;
$message = stripslashes($message);
mail(“[email protected]“,”Contact form request submitted at thecrucibleproject.org”,$message,”From: your website”);

header(“Refresh: 0;url=http:/thankyou.html”);
?><?php
}
?>

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@joseph_liuauthorJun 19.2007 — No ideas?? I'm not sure if its even possible, but if someone has any thoughts please share ?
Copy linkTweet thisAlerts:
@tczbuJun 19.2007 — Try:

$comment = nl2br($comments);

That converts all the line breaks to </br>.
×

Success!

Help @joseph_liu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...