JC05
Apr 6 2006, 03:18 AM
I am trying to install a PHP form. I am using a tutorial I found in the tutorials section. It was really good, but I have a few problems. Here is the link, if you need it: http://www.trap17.com/forums/index.php?sho...ic=8118&hl=form Anyway, so I place the mailform.php in an html document on file manager right? So I do that. And I put it in the body: CODE <?php $Name = $_POST['Name']; $Subject = $_POST['Subject']; $Email = $_POST['Email']; $Site = $_POST['Site']; $Message=$_POST['Message']; $align = $_POST['align']; $to = "$EmailTo"; $subject = "$Subject"; $body = "$Message\n\n\n$Site\nBy: $Name"; $headers = "From: $Email\n"; mail($to,$subject,$body,$headers); // After they've clicked "Send", this is where they are going... Change it to where you want them to go. header("Location: sent.htm"); ?>
I don't think I need to edit anything there right? I have all the other files set up, but there is a problem. When I go to do it, it sends the message to my email, but shows: QUOTE Warning: Cannot modify header information - headers already sent by (output started at /home/jc05/public_html/mailform.php:2) in /home/jc05/public_html/mailform.php on line 20
So I put it in the header, and it shows: QUOTE Warning: Cannot modify header information - headers already sent by (output started at /home/jc05/public_html/mailform.php:2) in /home/jc05/public_html/mailform.php on line 14
So whats up? There seems to be problems here. Does anyone know? I would really appreciate your help. Thanks in advance dudes 
Reply
Albus Dumbledore
Apr 6 2006, 03:37 AM
a few things, the link to your site where the contact forum is located might help us a little, and i uploaded what was onthe post in the link you provided and i had no problem with it... did you modify the code in any way shape or form? which it doesn't look like it..
Reply
Tyssen
Apr 6 2006, 04:09 AM
Problems with 'headers already sent' usually indicates you have some HTML above your PHP which you can't do.
Reply
jlhaslip
Apr 6 2006, 05:09 AM
Have a look at this script. I wrote it for one of my sites. CODE <?php // move these variables to a cfg.ini file included at the head of this file??? $site_email = 'jlhaslip@yahoo.ca'; $site_name = 'Web Site Template Distibution File'; if (isset($_POST['posted'])) { $email = trim($_POST['email']); $f_name = trim($_POST['first_name']); $l_name = trim($_POST['last_name']); $body = trim($_POST['note_wide']) ; $date = trim(date("D M j G:i:s T Y")); $name = $f_name . ' ' . $l_name; $theresults = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $email, $trashed);
if ( $f_name == "" || $f_name == " ") { echo '<p><span class="border bold red">A first name is required</span></p>'; } elseif ( $l_name == "" || $l_name == " " ) { echo '<p><span class="border bold red">A last name is required</span></p>'; } elseif ( $email == "" || $email == " " ) { echo '<p><span class="border bold red">An email address is required</span></p>'; } elseif (!$theresults) { echo '<p><span class="border bold red">The email address must be in a valid form similar to " your_name@example.com ".</span></p>'; }
elseif ( $body == "" || $body == " " ) { echo '<p><span class="border bold red">A message body is required</span></p>'; } } if ( $f_name && $l_name && $email && $body) { $file_name = "message_data.txt"; // Error Supress the fopen $handle = @fopen($file_name, "a"); // Check for successful fopen if (!$handle) { // error message and exit if no file handle available echo "File Handle Not Available For Use"; exit; } $body = strip_tags(str_replace( "\r" , ' ' , $body )); $body = str_replace( "\n" , ' ' , $body ); $body = str_replace( ',' , '' , $body ); $body = str_replace( "\'" , '&' , $body ); $body = str_replace( "\"" , '&' , $body ); $message_string = $date . ' , ' . $name . ' , ' . $email . ',' . $body . ',' . $_SERVER['REMOTE_ADDR']."\r\n"; fwrite($handle, $message_string); //close the open file prior to ending fclose($handle); if (@mail( $site_email, $site_name, $body,"From: $email <$name>\r\n")) { echo '<p class="border"><span class="bold red">Thank you for submitting this message. </span><br /><br /><span class="bold">Your comments and requests are important to us. If a reply is required, you can expect to hear from us shortly.</span><br /><br /><span class="bold red">Thanks again.</span> Select from the Menu to navigate to another page, or <a href="index.html" title=" Return to the site Home Page"> here </a> to reurn to the Index page..</p>'; unset($_POST);$_POST['posted'] = 'false';
} else { echo "<p class=\"border red\">Message failed to be accepted by the Mail system. <br /><span class=\"bold\">Please send the message to $site_email from your own email program.</span> <br />The site has been sent a report of the mail system failure, but not the contents of the message.<br /> Be certain to alter the permissions of the message data file to at minimum '666'.<br />We will endevour to correct the problem immediately.</p>"; unset($_POST);$_POST['posted'] = 'false';
} }; ?> <form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data"> <?php if (!isset($_POST['posted'])) { echo '<p><strong>All</strong> fields are required.</p>';} ?> <fieldset><legend>Personal Information</legend> <div class="notes"> <h4>Personal Information</h4> <p class="last">Please enter your name and a valid email address, then your message.<br /> We will never sell or disclose your email address to anyone. </p> </div> <div class="required"> <label for="first_name">First Name:</label> <input type="text" name="first_name" id="first_name" class="inputText" size="20" maxlength="40" value="<?php echo $_POST['first_name'] ?>" /> </div> <div class="hidden"> <input type="hidden" name="posted" value="true" /> </div> <div class="required"> <label for="last_name">Last Name:</label> <input type="text" name="last_name" id="last_name" class="inputText" size="20" maxlength="40" value="<?php echo $_POST['last_name'] ?>" /> </div> <div class="required"> <label for="email">Email:</label> <input type="text" name="email" id="email" class="inputText" size="40" maxlength="100" value="<?php echo $_POST['email'] ?>" /> </div>
<fieldset> <div class="required wide"> <label for="note_wide">Your Message:</label> <textarea name="note_wide" id="note_wide" class="inputTextarea" rows="6" cols="55"><?php echo $_POST['note_wide'] ?></textarea> <br /> <small>We would love to get your feedback or any comments on your experience with us.</small> </div> </fieldset> <fieldset> <div class="submit"> <div> <input type="submit" class="inputSubmit" value="Submit »" /> <input type="reset" class="inputSubmit" value="Reset Form" /> </div> </div> </fieldset> </form> </div>
Instead of having an automatic redirect, there is a message which displays the results of the form handling and if successful, a link to return to a defined page. It does require a client to interact with the page on completion, but it also provides them with an indication of the results of this Form submission, so there is a trade-off. In addition to sending an email, it also writes a message to a data file which I have a script to print-out, so if you want that, please send me a message and I'll provide it, too.
Reply
JC05
Apr 6 2006, 03:52 PM
Tyssen: Tyssen gets the cake. Dude that is awesome thanks! I was realy getting confused. I had a little bit of html above it, just a body tag with the BG color, and that is what was gumming the whole thing up. And to everyone, thanks for your help, couldn't have done it without you, Cheers!
Reply
gaea
Apr 6 2006, 05:47 PM
Just a heads up: Your script doesn't provide any error checking or validation...which means people can leave it blank or just enter garbage values. It also doesn't have any injection protection, which means spammers could use it to send out craploads of spam. If you're interested in a script without these issues check out: http://www.trap17.com/forums/index.php?sho...14entry240314
Reply
trace-uk
Apr 6 2006, 07:04 PM
I found it alot easier to use the free php form from www.thesitewizard.com its very easy to set up.
Reply
JC05
Apr 7 2006, 03:04 AM
Well I tried something new, I edited the fields, and put new ones in, but is only sending me a few. And it is not very good. Out of all fields, it only send me the name, email, subject, and that is it. What is wrong? Here is the code I am using: CODE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body bgcolor="#ffffff"> <form action="mailform.php" method="post"> <input type=hidden name=EmailTo value="emailhere"> <br>Your Name: <br><input type="text" value="" name="Name"> <br>Subject: <br> <input type="text" value="" name="Subject"> <br>Your Email: <br> <input type="text" value="" name="Email"> <br>How did you find us?: <br><select name="Found Through:"> <option value="Search Engine" selected="selected">Search Engine</option> <option value="Newspaper/Magazine">Newspaper/Magazine</option> <option value="Television/Radio">Television/Radio</option> <option value="Online Advertising">Online Advertising</option> <option value="Offline Advertising">Offline Advertising</option> <option value="Word of mouth">Word of mouth</option> <option value="Other">Other</option></select> <br>What Type Of Request is This? (Required) <br><select name="Request type:"> <option value="Custom Computer" selected="selected">Custom Computer</option> <option value="Standard Package (See below)">Standard Package (See below)</option> <option value="Question or Comment">Question or Comment</option></select> <br>Package (If requesting premade) <br><select name="Package #:"> <option value="Basic" selected="selected">Basic</option> <option value="Home/Office">Home/Office</option> <option value="Ultimate Gaming">Ultimate Gaming</option></select> <br>Custom Specs/Package Modification <br><textarea name="Custom Specs/Package Modification" rows="6" cols="30"> </textarea> <br>Questions/Comments <br><textarea name="Questions/Comments" rows="6" cols="30"> </textarea> <br> <input type="submit" value="Send"> <input type="reset" value="Reset"></form> <p><a href="java script:history.back()">Go Back</a></p> </body> </html>
Like I said, I am using this code: http://www.trap17.com/forums/index.php?sho...ic=8118&hl=form and I actually realized that there has to be a code in the mailform.php for every field. Is that right? Since it will only send you what the command there says to right? Anyway, could someone please edit that mailform code at the other page for the forms with the supplied code? I would really appreciate it. I wil link on the main page of my site to anyone who will. Thanks! Thanks.
Reply
Recent Queries:--
windows xp sp2 $_post empty - 1201.53 hr back. (1)
Similar Topics
Keywords : problems, php, form
- Php Problems
Clan Web site Problem (3)
Problems With Data Formatting
(2) I have a MySQL database which stores articles. A sample article would look like this: CODE This
is a body. This is a body.This is a body.This is a body.This is a body.This is a body.This is a
body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This
is a body.This is a body.This is a body.This is a body. This is a body.This is a body.This is a
body.This is a body.This is a body.This is a body.This is a body.This is a body.This is a body.This
is a body.This is a body.This is a body.This is a body.This is a body. That'....
Problems With Php
(5) Recently, my system was infected by a Trojan Horse. Since then, I've been finding files missing
and now my PHP will not work, my Apache server will not display PHP files, i've tried getting
rid of the files in my C:\Windows and C:\Windows\system32 folders but nothing is
working. (it comes up with 'file in use') All help greatly appreciated.....
Preg_replace Problems
(7) Sigh... preg_replace is getting very annoying for me. Could sombody tell me what I'm doing
wrong? Im making a bbcode replace for the forums I made, and preg_replace is being a b****...
Right now Im working on the tag, and I want to check for valid URL's, because idiots in the
forum are adding js and stuff in the image tags and messing it all up. So i put a function in the
array that holds all of the replacements: CODE
$main_search=array('/\[b\](.*?)\[\/b\]
/is','/\[i\ ....
Mysql Authentication Problems
(11) I installed the new version of both php and mysql on my computer and I am trying to work on a
database. The problem is the following. Even though I have the latest version of both php and mysql,
and I have created users in the new mysql version, I still get the problem that I get an error
message about authentication problems. I have no clue what I am doing wrong. It did work for a short
period of time, but somehow it is no longer working. Is there anyone who has a tutorial on how to
install both php and mysql? I have the feeling that there are a lot of settings in my.in....
Odbc Form Problems
(0) Hy everyone! I am moderately familiar
with PHP and have been using it for a couple years for various different things.
Basic information about my system:
PHP 5 MySQL 4.1 Apache Windows XP Pro I'm using
PHP/MySQL for a web-based server and have an ODBC set up in my office. I'm running into some
problems using the ODBC code as opposed to the MySQL code in some scripts I ha....
Phpnuke Newsletter Sending Problems
(0) i have a problem sending newsletters....when i send them no1 receives it...i tried sending to the
registered users on my site which im in and i didnt recieve it in my mail...i dont know why this is
happening...it says the newsletter is sent...but we get nothing in our mail... heres the code
QUOTE /************************************************************************/ /* PHP-NUKE:
Web Portal System */ /* ===========================
*/ /* ....
Major Problems With Php Script
Hold on for this one! (8) Okay, so I got a php script for my site called php Bible. So I get it and go to install it, and
then the problems start. You see it uses php, dud, to search and view scripture. So here are the
instructions: QUOTE 1) Upload the files to a useful place inside your web server's
document tree. 2) Change the things that look wrong in config.php. 3) Make sure "AcceptPathInfo
ON" (or analogous) is somewhere in your PHP file section of your web server config. 4) Go over
steps 2 and 3 again, because you probably missed something for lack of documentation. So....
Include Funtion Php Problems
in xammp and php 5.1.1 (11) Hi, I just recently installed the latest versin of XAMMP on my computer which comes with php5.1.1
and i have been noticing some problems with the include(); funtion. This is a code that worked
fine on trap17 hosting so I am thinking it has something to do with the php version of 5.1.1 since
trap17 uses 4.3.X. Now what the actual problem is is using the variables in the include function.
If i have a normal include sentence like this one: CODE include "hello.php"; then it
works fine but as soon as i start using variables it somehow dosent work at all. ....
<? Include ?> Problems
(4) Well, I'm new to PHP, and I get tons of problems when I use the include tags: Let's say my
site is www.mysite.com, and the menu is www.mysite.com/menu.htm. The site I want to include menu.htm
in is not in the same folder as menu.htm, but in "folder2": www.mysite.com/folder2/index.php The
images in menu.htm are located in it's own folder: www.mysite.com/images. However, when I load
index.php with , the images won't load. Then I try to check the image location and it says that
the images that didn't load was located in www.mysite.com/folder2/images ....
Browser Problems, Maybe?
Firefox vs IE (6) Alright, I coded something the other day for the game I am working on making, and a few of my
friends I allowed to get on it and test things out. Well....the ones that were on IE their
characters were made but the User variable as in which account they were on just stayed blank, while
with my friends that were on Firefox, everything worked fine and they could play perfectly... So I
was wondering, with PHP sql codes being sent to the database, is there something special you have to
do to make it work on both, or could it be a setting on the IE that was messing with it......
Postnuke Install Problems On Subdomains
(1) I'm trying to install PostNuke on a empty server I allready got PostNuke downloaded and uploaded
the downloaded files to the server but I can't get it to work. I'm trying to do this on 2
servers both are sub-domains and both support php. One of them has a MySQL database and MyAdmin but
I can't find them anywhere on the sub-domain. I'm pretty new to this and any advise would be
more then welcome to me. I tryed looking for a MySQL database to install but when I do I get
something like 30 different versions and don't know whitch one I need I tryed th....
Php And Gd Tutorial
I'm having problems (6) I am trying to learn PHP and was wondering what is wrong with the tutorals on this site:
http://www.phpfreaks.com/tutorials/105/1.php I copied the code between the body tages in my site,
and am returned with an error regarding headers. Does anybody why this is?....
Problems With Apostrophes [ ' ] In Php
(4) Yes I have another problem. I have a blog that I made with php and mysql. It's working just
fine except for the text being displayed on the page. Everytime there's an apostrophe
encountered, *something puts a slash before it. It's fine in the database only the page.
Probably a problem with PHP. I hope you understand what I say. Here's a sample line displayed
in my blog: -- It\'s Saturday but I\'m still in the office. -- ....
Ftp Script Problems - Authentication Failure
(3) I uploaded the code as a text file because it's pretty big: http://beeseven.trap17.com/ftp.txt
As I said it can't login. I get this error: Warning : ftp_login(): Authentication failed,
sorry in /home/beeseven/public_html/ftp.php on line 45 I think it might have something to do
with character encoding, but I'm not sure. If you think it is, what kind of encoding would work
as if I typed it directly? I tried putting it in the file, but then I got the missing required
fields error.....
Mysql Relational Problems
(3) didn't know where to post this but since I build this database with php, I post it here. I have
to build a relational database 4 a school project. Made a webbased interface and made a database
with primary&foreign keys and not null fields to preserve the integrety of my database. -When I
insert an empty field or I just don't give the field where the field has the property NOT NULL
it just fills in nothing or some default value (it ignores the not null property). -When I insert 2
rows with the same primary key in the same table it doesn't throw an error but ....
Looking for problems, php, form
|
*RANDOM STUFF*
*SIMILAR VIDEOS*
Searching Video's for problems, php, form
*MORE FROM TRAP17.COM*
|
advertisement
|
|