e-mail screen problem

This is a discussion on "e-mail screen problem" within the PHP Forum section. This forum, and the thread "e-mail screen problem are both part of the Program Your Website category.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old May 13th, 2007, 19:13
Junior Member
Join Date: May 2007
Location: bahrain
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
e-mail screen problem

Hi
I have this question:

The email screen will display the old email address and ask for the new email address. Once a student enters the new email address, it will automatically send an email to that address and take the student to a new screen that says that the email has been sent and display a link to go back to the main panel.

I did it like this but it doesn't seem to work

Code: Select all
<?php
session_start();
$stid=$_SESSION['sid'];
if(!isset($stid)){
include("anauthorized.html");
exit();
}
?>
//Some html codes here I deleted just to post PHP codes
 
    include('DB_connectscript.php');
    if(isset($_POST['submit']))
    {
     if($form_errors = check())
     {
      show_form($form_errors);
     }
     else
     {
      process();
     }
    }
    else
    {
     show_form();
    }
 
   function show_form($errors='')
   {
    print "<br/>";
    print "<br/>";
    print "<br/>";
    print "<form method='POST' action='".$_SERVER['PHP_SELF']."'>";
    print "<h3 align = 'center'>Please fill your data in the following fields:</h1><table align = 'center' border='0' dir='ltr'>";
 
    print "<tr>";
    print "<td colspan='2'>";
    if ($errors) {
     print "<font color='#FF0000'>";
     print "<ul><li>";
     print implode("</li><li>",$errors);
     print "</li></ul>";
    }
    print "</tr>";
 
    print "<tr>";
    print "<td><font size='2'> Enter your new E-mail address </font></td><td><input type='text' name='mail'></td>";
    print "</tr>";
    print "<tr>";
    print "<td colspan='2'>";
    print "<p align='center'>";
    print "<input type='submit' value='Submit' name='submit' dir='ltr'>";
    print "</tr>";
    print "</table>";
    print "</form>";
    print "<br/>";
    print "<br/>";
    print "<br/>";
   }
   function check()
   {
    global $stid;
    $errors = array();
    if (!$_POST['mail'])
    {
 
     $errors[] ='You did not fill in a required field';
     return $errors;
    }
    if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_POST['mail'])) 
    {
     $errors[] ='Invalid E-mail Address.';
     return $errors;
    } 
   } 
   function process()
   {
    global $stid;
    $mail = $_POST['mail'];
    $update = "UPDATE STUDENT SET EMAIL = '$mail' WHERE SID = '$stid'";
    $result= mysql_query($update);
    if(!$result)
    {
     print "Update ERROR:". mysql_error();
     exit();
    }
    else
    {
     echo '<META HTTP-EQUIV="Refresh" CONTENT="3;URL=userpage.php">';
    }
   }
   ?>
Is that correct??
thank you
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old May 24th, 2007, 08:21
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
Re: e-mail screen problem

might be going blind here .... but where is your mail() statement?

Also, I like to sepearate my forms from the processing ... that way you could use the header function at the bottom, as its very unlikley you'd have any output on a pure processing page.

Last edited by Accurax; May 24th, 2007 at 08:24.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old May 24th, 2007, 12:24
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: e-mail screen problem

Quote:
Originally Posted by Accurax View Post
Also, I like to sepearate my forms from the processing ... that way you could use the header function at the bottom, as its very unlikley you'd have any output on a pure processing page.
LOL, I've gotten to just about the opposite point -- I like include everything on one page if it doesn't hurt the initial load time. It may be an eccentricity, I don't know -- it certainly takes more exacting organization as you have, by definition, at least one more layer of "if" statements.

You can use conditional headers fine, you just have to have common formatting modularized.

That is, the biggest downside for including form handlers and forms on one page is, that if you do very much with the http headers (including session and cookie work), it sometimes deprives you of the ability to put common html in one place. Eventually the need to send header information before calling the http response may require you to repeat a section of html inside different conditional branches.

This is, I think, solved fully by putting the repetitive matter in a class or include. I hope I am correct that php won't load the include unless and until it hits a valid conditional trigger.

Well maybe I'd better ask this as a question. I am thinking that in example #1 the html "Tons of nonsense" is going to be loaded into memory twice, whereas in example #2 it will be loaded only once (for a single http request):
#1
PHP: Select all

<?php
if($x) { ?>
<div> . . . Tons of nonsense . . . </div>
<div> . . . Tons of drivel . . . </div>
<?php } else { ?>
<div> . . . Tons of nonsense . . . </div>
<div> . . . Tons of different drivel . . . </div>
<?php ?>
#2
PHP: Select all

<?php
if($x) { ?>
include('./tons_of_nonsense.inc');
<div> . . . Tons of drivel . . . </div>
<?php } else { ?>
include('./tons_of_nonsense.inc');
 <div> . . . Tons of different drivel . . . </div>
<?php ?>
But one thing anyone would have to agree on -- it's essential to "see" the processing as a separate entity.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old May 29th, 2007, 08:44
Junior Member
Join Date: May 2007
Location: bahrain
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Re: e-mail screen problem

I forgot to add e-mail function lol I will add it right now!

I think using include makes the script looks better but I don't like to do that mostly.

thank you for replaying my friends
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
change, email

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Screen resolution problem jadebleh Starting Out 5 Nov 21st, 2007 21:50
problem with images when sending html page by mail juanb007 Web Page Design 4 Apr 29th, 2007 03:25
mail() problem asa_carter PHP Forum 4 May 10th, 2006 21:22
Problem with Screen Refreshing Stumpy_uk JavaScript Forum 1 Jan 10th, 2006 07:57


All times are GMT. The time now is 06:08.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42