Page 1 of 1

Page redirect after using Mail() function

Posted: Sun Jan 16, 2005 7:20 pm
by mmanders
Hi, I am writing a user authenticated website that uses php to authenticate users against a mySQL database. Everything works fine to a point... I send the user an email with random password for email validation... the email is received fine - and after that I want the user to be directed to a "signup success" page. For some reason, whether I include the HTML for this success page directly or as a php include, it does not get parsed and displayed. See code below! Thanks in advance for any help!

Max

Code: Select all

<?php
...
// everything works fine so far
...

mail($_POST&#1111;'newEmail'],"Your Password for the elearnJava Website", $message, "From:elearnJava Webmaster <webmaster@realisedesign.co.uk>");
...
// mail is sent and received successfully - page should load saying
// success

include 'success.php';
// page doesnt load - browser status bar says 'done'
endif;
?>

Re: Page redirect after using Mail() function

Posted: Sun Jan 16, 2005 7:31 pm
by timvw
mmanders wrote:

Code: Select all

<?php
error_reporting(E_ALL);
......
require_once('success.php');
?>
my guess is that i can't find success.php (might want to read the documentation on include/require where it says where those functions will search for the file)

Tried various combinations of include

Posted: Sun Jan 16, 2005 7:37 pm
by mmanders
Thanks for quick reply,

I have tried numerous forms of include... and checked that my include path is ok...

Have tried

Code: Select all

include('success.php');
include("success.php");
include "success.php";
include 'success.php';
and all of the above with the full path to success.php specified, i.e.
/login/success.php

Hmph - getting very annoyed now :cry:

Posted: Sun Jan 16, 2005 7:46 pm
by feyd
/login/success.php very very very likely isn't the full path. More likely it's /home/yourusername/public_html/login/success.php but you shouldn't have to do that.. Check the path of the executing file: $_SERVER['PATH_TRANSLATED'] as well as __FILE__ .. and check the include paths to see where they are through phpinfo()

Posted: Sun Jan 16, 2005 7:50 pm
by mmanders
I'm doing all this on a local XP testing server... I have http://project
setup as a virtual host and the actual website is installed in
c:\www\project... so http://project points to c:\www\project.

As such, I think /login/success.php is the full path as far as the web server is concerned since this is a web root relative url
(n.b. path to success.php is c:\www\project\login\success.php)

Posted: Sun Jan 16, 2005 7:56 pm
by feyd
include/require uses file system, not web.

Posted: Sun Jan 16, 2005 7:58 pm
by mmanders
could you elaborate on that? how should I include a file 'success.php'
give it is located at c:\www\project\login\success.php, where my virtual host document_root is c:\www\project!?

Posted: Sun Jan 16, 2005 8:17 pm
by feyd
most likely.. it's /www/project/login/success.php for the full path.

However, if you use ini_set()/set_include_path() you can almost entirely ignore the real path, just have to remember it was changed there ;) :

Code: Select all

$old_path = ini_get('include_path');
ini_set('include_path','/www/project/');

include('login/success.php');

ini_set('include_path',$old_path);