473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Email form

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
te**@test.com and the user logged out.

What is the easiest way to achieve this?

Many thanks

Alec

Aug 28 '06 #1
1 1367
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
te**@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
Aug 28 '06 #2

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

Similar topics

6
by: bojanraic | last post by:
Hi! I recently started playing with Python CGI, and I was happy that my basic input-name--print-hello-name CGI form example worked, so I thought I should advance to somew\hat more complicated...
4
by: dmiller23462 | last post by:
So here's my problem.....I need to set up different email distributions based on which option in the following Select form has been chosen....For instance if "Putaway" is chosen it needs to email...
88
by: Mike | last post by:
Is there a way to determine what a user's default email client is? I read a post from 3 years ago that said no. I guess I'm hoping something has come along since then.
4
by: Ken D. | last post by:
I have an asp page that collects data on referrals. The user inputs the information and selects the rep to receive the referral. My data is being saved to a backend database (SQL) and the user is...
26
by: libsfan01 | last post by:
Hi all! Can anyone show me how to check and email field on a form for the existence of these two characters. Kind regards Marc
2
by: kennykenn | last post by:
Hi, Ive producd code to send an email after capturing info off a form,it works fine locally but when i put it live it doesnt work! the code is stopin at 'msg.send' any ideas, here the code! ...
5
by: simononestop | last post by:
Hi im totally new to perl this is my first go at using it (I normally use asp). I have set up a form with a cgi script from demon hosting. I have edited the script and the form works it sends me an...
2
by: sindhudixit | last post by:
Hey, I am having a user fill out a form then the fields are going to uploaded to my database. So, at this point, when the user hits the submit button I want three things to happen: 1. The...
0
by: gervo | last post by:
I have built a series of email forms in flash MX. using perl. the forms work for some people but not all and I was hoping some one could help me out. Here is the Actionscript on the send button ...
4
by: zufie | last post by:
I have a main form containing a command SEND button that prompts an email form to pop up. The email address(es) that are supposed to appear on the email form are those corresponding to the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.