473,584 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

new to php

This is my first attempt ever at php can anyone glance over this
code segmant and tell me were I am going wrong please

---- HTML ----
<html>
<head>
<title>Email Me</title>
<body>
<p>
</head>
<table width="400">
<tr>
<td>
<form action="email.p hp" method="POST">
Subject:
<br>
<input type="text" name="subject" size="20" maxlength="30">
<p>
Message:
<br>
<textarea rows="8" name="message" cols="25"></textarea>

<p>
<input type="submit" value="Send">
</form>
</td>
</tr>
</table>
</body>
</html>

------------------------------
----PHP -------
<html>
<body>

<?php
$to = "ot******@aol.c om";
$from = "desot******@ao l.com";
// $subject = "This is a test email";
// $message = "Dear Desmond,\n\n\n This is just a test email.\n\n
From Chris.";


// $headers = "From: $from\r\n";

$success = mail($to, $HTTP_POST_VARS["subject"],
$HTTP_POST_VARS["message"]);
if ($success)
echo "The email to $to from $from was successfully sent";
else
echo "An error occurred when sending the email to $to from
$from";
?>

</body>
</html>

Jul 17 '05 #1
12 1365
Desmond wrote:
This is my first attempt ever at php can anyone glance over this code
segmant and tell me were I am going wrong please
As I often like to ask when people ask such not well thought out
questions: What was your first indication that it failed? Also, what
have you done in your attempts to debug it?
---- HTML ----
<html>
<head>
<title>Email Me</title>
<body>
<p>
</head>
<table width="400">
<tr>
<td>
<form action="email.p hp" method="POST">
Subject:
<br>
<input type="text" name="subject" size="20" maxlength="30">
<p>
Message:
<br>
<textarea rows="8" name="message" cols="25"></textarea>

<p>
<input type="submit" value="Send">
</form>
</td>
</tr>
</table>
</body>
</html>

------------------------------
----PHP -------
<html>
<body>

<?php
$to = "ot******@aol.c om";
$from = "desot******@ao l.com";
// $subject = "This is a test email";
// $message = "Dear Desmond,\n\n\n This is just a test email.\n\n
From Chris.";


// $headers = "From: $from\r\n";

$success = mail($to, $HTTP_POST_VARS["subject"],
$HTTP_POST_VARS["message"]);
if ($success)
echo "The email to $to from $from was successfully sent";
else
echo "An error occurred when sending the email to $to from
$from";
?>

</body>
</html>

--
Headline: Bear takes over Disneyland in Pooh D'Etat!

Jul 17 '05 #2
*** Desmond wrote/escribió (15 Jun 2005 07:43:33 -0700):
This is my first attempt ever at php can anyone glance over this
code segmant and tell me were I am going wrong please
Your main mistake is that you've tagged your usenet message to be ignored.
Subject line should be used to provide a short description of what your
message is about; that way, when there's traffic in the group, it can call
the attention of someone who may have the knowledge to help. Also, you
cannot just paste 50 lines of code and let others figure out what your
problem is. Explain what your want to do and how your code fails to do so.
Error messages are especially helpful.

<body>
<p>
</head>
To begin with, this is not valid HTML. Check http://validator.w3.org/
<form action="email.p hp" method="POST">
$success = mail($to, $HTTP_POST_VARS["subject"],
$HTTP_POST_VARS["message"]);


$HTTP_POST_VARS is deprecated, use $_POST instead.
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #3
Alvaro G Vicario wrote:
<form action="email.p hp" method="POST">
$success = mail($to, $HTTP_POST_VARS["subject"],
$HTTP_POST_VA RS["message"]);


$HTTP_POST_VARS is deprecated, use $_POST instead.


And filter the subject & message input so there isn't anything nasty in
it before using the submitted info. (In this case, you may want to do
something like strip_tags() on it since it's not an HTML MIME message.)

Best to get in the practice of validating/filtering input and output
from the beginning - event if it isn't necessary. It will save you a lot
of headaches down the road...

--
Justin Koivisto - ju****@koivi.co m
http://koivi.com
Jul 17 '05 #4
I have downloaded a tutorial learn php in 6 days. But there is an area
i don't understand. I am
told to use

<form action = "action1.ph p3" method = "POST">

but how do i asign a php variable to it so I can use the following

$success = mail($to, $subjec, $message);

Please Desmond.

Jul 17 '05 #5
The indication that it failed was there was no email sent even though
it said so. All I want to do is retreave the variables from the html
page and send an email.

this is it. I am new to php but ok on html

http://www.des-otoole.co.uk/email.html

Jul 17 '05 #7
Desmond wrote:
The indication that it failed was there was no email sent even though
it said so.
There that wasn't that hard was it. In the future always include what
actually happened, error message, etc. - otherwise we are just guessing.

Now did you think to stop and check to make sure what you put in was
correct? By that I mean you used certain variables but were you sure
that they contained what you thought they should contain? Adding display
like debugging statements is always helpful.
All I want to do is retreave the variables from the html page and send
an email.
Yes. Break the problem down and work on a small subset of the problem.
Validate your assumptions before proceeding further. Another poster
already hinted to the probable problem. IOW verify that you are doing
"A" properly first before attempting "B". "A" here = "retrieve the
variables from the html page". Are you sure you've retrieved them properly?

Instead of plodding onward to emailing them how about simply displaying
them to make sure they are correct first. Your email.php can instead of
emailing simply write out HTML displaying the contents of what is passed
in. Once you're sure that's correct then go onward.

So instead of:

<html>
<body>

<?php
$to = "ot******@aol.c om";
$from = "desot******@ao l.com";
// $subject = "This is a test email";
// $message = "Dear Desmond,\n\n\n This is just a test email.\n\nFrom Chris.";
// $headers = "From: $from\r\n";

$success = mail($to, $HTTP_POST_VARS["subject"],
$HTTP_POST_VARS["message"]);
if ($success)
echo "The email to $to from $from was successfully sent";
else
echo "An error occurred when sending the email to $to from $from";
?>

</body>
</html>

Try:

<html>
<body>

<?php
$to = "ot******@aol.c om";
$from = "desot******@ao l.com";

$subject = $_POST["subject"];
$message = $_POST["message"];

print "subject = '$subject'<br>" ;
print "message = '$message'<br>" ;

if (mail($to, $subject], $message)) {
echo "The email to $to from $from was successfully sent";
} else {
echo "Unable to send message";
}
?>

</body>
</html>

Additionally read up on the documentation about the function you are
using - mail - http://us3.php.net/manual/en/function.mail.php. Also
refer to http://us3.php.net/manual/en/ref.mail.php, especially the user
comments about specifying a proper From address.
this is it. I am new to php but ok on html
I'd say your html could use a little work too! ;-)
http://www.des-otoole.co.uk/email.html
--
Too many freaks, not enough circuses.

Jul 17 '05 #8
Can someone please tel me the equivelent in PHP of this vbscript

Response.Redire ct "acknowledge".h tml Thanks

Jul 17 '05 #9
*** Desmond wrote/escribió (16 Jun 2005 02:58:54 -0700):
Can someone please tel me the equivelent in PHP of this vbscript

Response.Redire ct "acknowledge".h tml Thanks


header('Locatio n: http://' . $_SERVER['HTTP_HOST] . '/acknowledge".ht ml');
exit;
Although it does work with a relative location, I believe HTTP v1.1
requires a full URL.

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11195
by: William C. White | last post by:
Does anyone know of a way to use PHP /w Authorize.net AIM without using cURL? Our website is hosted on a shared drive and the webhost company doesn't installed additional software (such as cURL) on the server because of that. Our site will have an SSL certificate next week, so I would like to use AIM instead of SIM, however, I don't know how...
2
5791
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues to execute the code until the browser send his reply to the header instruction. So an exit(); after each redirection won't hurt at all
3
22986
by: James | last post by:
Hi, I have a form with 2 fields. 'A' 'B' The user completes one of the fields and the form is submitted. On the results page I want to run a query, but this will change subject to which field is completed.
0
8456
by: Ollivier Robert | last post by:
Hello, I'm trying to link PHP with Oracle 9.2.0/OCI8 with gcc 3.2.3 on a Solaris9 system. The link succeeds but everytime I try to run php, I get a SEGV from inside the libcnltsh.so library. 354 roberto@ausone:Build/php-4.3.2> ldd /opt/php4/bin/php libsablot.so.0 => /usr/local/lib/libsablot.so.0 libstdc++.so.5 => ...
0
7829
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8189
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8198
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6587
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3850
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2336
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1438
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.