Reply to Re: Email form

Your name:

Reply:


Posted by Erwin Moller on 08/28/06 12:30

Alec wrote:

> Sorry beginners question..
>
> The following link http://www.schott-systeme.com/en/logintest.php is a
> test secure login page for our customers.
>
> Type in 123-456-BSE and login, and it returns a form for the customer
> to check three typical bits of into, ie refno, name and email. This
> works ok and code is below.
>
> <?php
> //Process login
> if (isset($_POST['companyID'])) {
> // Check login
> $companyID = $_POST['companyID'];
> $resultlogin = @mysql_query ("SELECT userID, username, useremail FROM
> schott_news WHERE userID='$companyID'");
> while ($row = mysql_fetch_array($resultlogin))
> {
> $userID = $row['userID'];
> $username = $row['username'];
> $useremail = $row['useremail'];
> }
> if ($_POST['companyID'] = $userID)
> {
> $_SESSION['authorized'] = TRUE;
> }
> }
> //Process logout
> if (isset($_SESSION['authorized'])) {
> //Display secure information
> ?>
> <h1>Please complete all information</h1>
> <div>
> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
> <label>UserID:
> <input type="text" name="code" value="<?php echo $userID;
> ?>"/></label><br />
> <label>User Name:
> <input type="text" name="name" value="<?php echo $username;
> ?>"/></label><br />
> <label>User E-Mail:
> <input type="text" name="email" value="<?php echo $useremail;
> ?>"/></label>
> <input type="submit" value="Submit" />
> </form>
> </div>
> <p><a href="<?php echo $_SERVER['PHP_SELF']; ?>?logout=1">Log
> OUT</a></p>
> <?php
> } else {
> //Display login form
> ?>
> <h1>Please Enter Company Ref No</h1>
> <div>
> <form action="<?php echo $_SERVER['PHP_SELF']; ?>"
> method="post">
>
> <label>User ID:
> <input type="text" name="companyID" /></label>
> <input type="submit" value="log IN" />
> </form>
> </div>
> <?php
> }
> ?>
>
> I want to now click on Submit, and the form results are emailed to
> test@test.com and the user logged out.
>
> What is the easiest way to achieve this?

Hi,

A few pointers:
1) Use the buildfunction mail().
See www.php.net for details.

2) When you use one script to do everything, you are only making your life
unneeded difficult. You code will end up with a spaghettilike logictree to
handle each situation. A situation you should avoid.
Consider changing your action-tag in the form into another script, like
logout_and_email.php where you handle the logic.
You script shows that you already know how to retrieve information from a
POST. I suggest you take the logic for emailing to a new script.

3) How to end a session?
This can be done in many ways.
Here is one that empties the session, but keeps the session (id) around for
future use:
$_SESSION = array();
or
session_destroy()


Read it all here:
http://nl3.php.net/manual/en/ref.session.php

Regards,
Erwin Moller

>
> Many thanks
>
> Alec

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация