?
Solved

Email thru a webpage

Posted on 2003-03-17
10
Medium Priority
?
258 Views
Last Modified: 2008-03-06
I'm trying make a feed-back form, so users can send me email thru a webpage.
I've tried the same code on Red7.1 with the source files of Apache and PHP
installed and on RH8.0 with the RPM's installed, with the same problem on both.
the email gets sent, but without the sender_name, sender_email or the message.
i got this code from the book:
PHP fast&easy web development/ Thickbook
and sendmail does work on both boxes.

here is the first page:

<HTML>
<HEAD>
<TITLE>Simple Feedback Form</title>
</head>
<BODY>

<FORM METHOD="post" ACTION="send_simpleform.php">


<P><strong>Your Name:</strong><br>
<INPUT type="text" NAME="sender_name" SIZE=30></p>

<P><strong>Your E-Mail Address:</strong><br>
<INPUT type="text" NAME="sender_email" SIZE=30></p>

<P><strong>Message:</strong><br>
<TEXTAREA NAME="message" COLS=30 ROWS=5 WRAP=virtual>
<P><INPUT TYPE="submit" NAME="submit" VALUE="Send This Form"></p>

</FORM>

</BODY>
</HTML>

here is the code for the second page;
<?php

$msg = "E-MAIL SENT FROM WWW SITE\n";
$msg .= "Sender's Name:\t$sender_name\n";
$msg .= "Sender's E-Mail:\t$sender_email\n";
$msg .= "Message:\t$message\n\n";

$to = "gary441@yahoo.com";
$subject = "Web Site Feedback";
$mailheaders = "From: My Web Site <> \n";
$mailheaders .= "Reply-To: $sender_email\n\n";

mail($to, $subject, $msg, $mailheaders);

?>

<HTML>
<HEAD>
<TITLE>Simple Feedback Form Sent</TITLE>
</HEAD>
<BODY>

<H1>The following e-mail has been sent:</H1>

<P><strong>Your Name:</strong><br>
<?php echo "$sender_name"; ?>

<P><strong>Your E-Mail Address:</strong><br>
<?php echo "$sender_email"; ?>

<P><strong>Message:</strong><br>
<?php echo "$message"; ?>


</BODY>
</HTML>

any ideas?
Thank You
Gary
0
Comment
Question by:Gary441
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 

Author Comment

by:Gary441
ID: 8153636
update
i tried hardcoding a msg in the send_simpleform.php
page( the second page) and the part i hardcoded in
gets sent, so it seems that for some reason that the
variables are not getting passed onto the second page.
Any ideas?

Thank you.
Gary
0
 
LVL 15

Accepted Solution

by:
VGR earned 150 total points
ID: 8153813
are you still in register_globals=On in your php.ini ?

Given your code, you should try :D :D
0
 

Author Comment

by:Gary441
ID: 8153884
register_globals=Off in my php.ini file.

what is :D :D? semi-colon twice?

Thanks
gary
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Gary441
ID: 8153948
opps...i mean semi-colon capital D twice?
0
 
LVL 15

Expert Comment

by:VGR
ID: 8154064
a big smile, I guess ;-)

Given your actual code, put register_globals=On

else you'll have to modify it all "for security reasons like the agression against Iraq's reasons" :D
0
 

Author Comment

by:Gary441
ID: 8154179
VGR
you are my hero!!! ha
that did it. the email gets sent correctly. but in the
second page, the variables aren't coming thru, so it looks, to the user who sent, that the email address, the subject and  message didnt go thru, even thou it did.
I've been playing with this code all morning.

Thank you very much.
gary
0
 

Author Comment

by:Gary441
ID: 8154418
IT WORKS!
with VGRs help and i had to change the user and group of the files to the same user as apache is using, which is apache. it works! finally!
Thanks again, VGR.

Gary
0
 
LVL 15

Expert Comment

by:VGR
ID: 8154440
cool :D

some "esprits chagrins" will tell you  that turning register_globals=On is 1)bad, 2)evil, 3)dangerous, 4)deprecated and obsolete soon , 5)bad programming : don't listen at them 8-)
0
 

Expert Comment

by:foran
ID: 8156236
here is a form that you would use to access the included email script--

part of email.html>>

<font size="+2">Send us an e-mail...</font> <br>
          </p>
          <form action="formmail.php" method="POST">
            <p><font size="+1">Your Name (required):</font> <br>
            <input type="text" name="Name" size="50"> </p>
            <p><font size="+1">Your E-mail (required):</font> <br>
            <input type="text" name="Email" size="50"> </p>
            <p><font size="+1">Your message (required):</font> <br>
            <textarea rows="6" name="Message" cols="45"></textarea> </p>
            <p><input type="submit" value="Click Once to Send" name="B1"><input type="reset"
            value="Clear" name="B2"> <br>
            </p>
          </form>


formmail.php >>>

<?php

// This script takes 3 input variables from a form:  Name, Email, Message

  $to = "webmaster@yourserverhere.com";
  $from = "From: $Email\r\n";
  $subject = "Website Form Submission";
  $text = "$Name\r\n$Email\r\n\r\n$Message";
  mail($to,$subject,$text,$from);
 
  header ("Location: http://www.yourserverhere.com");
?>
0
 

Expert Comment

by:hexabr
ID: 8159018
since register globals is off use $_POST global variables

eg:

in the main page:
.
.
<INPUT type="text" NAME="sender_name" SIZE=30></p>
.
.

in the send mail php:
.
.
.
$_POST["sender_name"]
.
.
.


this is much more secure, and remember checking the actual content of the $_POST vars and always use SetType() function
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question