473,908 Members | 5,094 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 1378
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
11272
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 to send data via POST over https and recieve data from the Authorize.net server over an https...
2
5869
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
23057
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
8512
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 => /usr/local/lib/libstdc++.so.5 libm.so.1 => /usr/lib/libm.so.1
0
10029
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9875
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11334
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10911
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10528
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9719
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8092
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5927
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.