473,804 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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='$compan yID'");
while ($row = mysql_fetch_arr ay($resultlogin ))
{
$userID = $row['userID'];
$username = $row['username'];
$useremail = $row['useremail'];
}
if ($_POST['companyID'] = $userID)
{
$_SESSION['authorized'] = TRUE;
}
}
//Process logout
if (isset($_SESSIO N['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">Lo g
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 1382
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='$compan yID'");
while ($row = mysql_fetch_arr ay($resultlogin ))
{
$userID = $row['userID'];
$username = $row['username'];
$useremail = $row['useremail'];
}
if ($_POST['companyID'] = $userID)
{
$_SESSION['authorized'] = TRUE;
}
}
//Process logout
if (isset($_SESSIO N['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">Lo g
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_emai l.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
5403
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 scripts. I'm trying to write a basic Python email CGI script to send email through HTML email form. I've seen a lot of examples out there, but nothing I tried so far seemed to work. So I would like to know what I am doing wrong.
4
3023
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 User1@here.whatever and User4@here.whatever but if "Loaded" is chosen it needs to email User2@here.whatever and User3@here.whatever, etc, etc... I'm aware that the only thing that really needs to change is the "Mail.AddAddress" line (at least...
88
12589
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
2347
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 receiving a confirmation page after hitting the Submit button. Now, what I need is a way to have an email sent to the rep that is selected in the drop down list on the asp form. I have a SQL table containing the reps and corresponding email...
26
2830
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
2495
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
2309
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 email. however all the information is missing form the email I only get the first form text field?? #!/bin/perl # ------------------------------------------------------------
2
2326
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 form uploads to a database (the following code does this) 2. An e-mail is sent to my sales team as well as the customer, which contains the form values . 3. I want the user to then be directed automatically to another webpage, after they hit the...
0
2045
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 on (release, keyPress "<Enter>") { if (company ne "" and first ne "" and last ne "" and phone ne "" and fax ne "" and mobile ne "" and email ne "" and address ne "" and city ne "" and state ne "" and zip ne "") { i = "0"; validmail = 0;...
4
3481
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 respective agency record appearing on the main form at the current time. Instead, what I get is the email form without the appropriate information in the textboxes of the email form.
0
10600
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
10350
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
10096
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
9174
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
7638
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
6866
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
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
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.