9, July 2008

redirect after succesful registration.php??? - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: redirect after succesful registration.php???
« previous next »
Pages: [1] Print

Author Topic: redirect after succesful registration.php???  (Read 1728 times)
What a dork
*
Posts: 17
110 credits
Members referred : 0


« on: Aug 24, 2006, 07:33:05 PM »

Hello Olaf,

As I am a newby this must be a laughable to you. I am applying your class and everything works great!

But after the registration.php page I want to redirect to a new page. Ofcourse I know that the form in registration.php posts to itself validate the form and process the registration. So I can't put a url in action="http://" (is now action=$_POST['PHP_SELF']). So I put in a If statement to redirect to an other page if the registration was successfull by using header("Location: ").

Now I think I found that header( ) doesn't work together with $_POST? Is this true and is there an other way to redirect after succesful registration? - scooter
« Last Edit: Aug 24, 2006, 09:56:54 PM by scooter »
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6274
38470 credits
Members referred : 374


It's time to use PHP5!


Re: redirect after succesful registration.php
« Reply #1 on: Aug 24, 2006, 10:07:31 PM »

Hello,

The problem is only that you can't output data from a page and redirect together but you can create a "registration success" page within the register.php

Code:
<?php
include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/access_user_class.php"); 

class 
myRegister extends Access_user {


function register_user($first_login$first_password$confirm_password$first_name$first_info$first_email) {
if ($this->check_new_password($first_password$confirm_password)) {
if (strlen($first_login) >= LOGIN_LENGTH) {
if ($this->check_email($first_email)) {
$this->user_email $first_email;
$this->user $first_login;
if ($this->check_user("new")) {
$this->the_msg $this->messages(12);
return false;
} else {
$sql sprintf("INSERT INTO %s (id, login, pw, real_name, extra_info, email, access_level, active) VALUES (NULL, %s, %s, %s, %s, %s, %d, 'n')"
$this->table_name,
$this->ins_string($first_login),
$this->ins_string(md5($first_password)),
$this->ins_string($first_name),
$this->ins_string($first_info),
$this->ins_string($this->user_email),
DEFAULT_ACCESS_LEVEL);
$ins_res mysql_query($sql) or die(mysql_error());
if ($ins_res) {
$this->id mysql_insert_id();
$this->user_pw $first_password;
if (!$this->auto_activation) {
$subject 39;
$body 40;
} else {
$subject 28;
$body 29;
}
if ($this->send_mail($this->user_email$body$subject)) {
$this->the_msg $this->messages(13);
return true;
} else {
mysql_query(sprintf("DELETE FROM %s WHERE id = %s"$this->table_name$this->id));
$this->the_msg $this->messages(14);
return false;
}
} else {
$this->the_msg $this->messages(15);
return false;
}
}
} else {
$this->the_msg $this->messages(16);
return false;
}
} else {
$this->the_msg $this->messages(17);
return false;
}
}
}
}

$new_member = new myRegister;

if (isset(
$_POST['Submit'])) { 
if ($new_member->register_user($_POST['login'], $_POST['password'], $_POST['confirm'], $_POST['name'], $_POST['info'], $_POST['email'])) {
header("Location: register_success.php");
}

$error $new_member->the_msg// error message
?>

<!-- your other html code -->



Last blog : 4th of July Lottery from TemplateMonster.com
What a dork
*
Posts: 17
110 credits
Members referred : 0


« Reply #2 on: Aug 24, 2006, 11:38:29 PM »

?... Ok, I get that. I'm going to try this out in the morning. Thanks a million for clearing this out so fast Olaf. See ye later.
What a dork
*
Posts: 17
110 credits
Members referred : 0


« Reply #3 on: Aug 25, 2006, 06:44:32 PM »

It didn't work? It ended up at: color=Red]echo "redirect wordt gestart <br>";[/color]
     header("Location: http://www.office-specialist.nl/rocfriese/register_success.php Visit through proxy");

but the redirect somehow doesn't start ?

See my code (is your code above):   - scooter



<?php
include($_SERVER['DOCUMENT_ROOT']."/classes/access_user/access_user_class.php");

class myRegister extends Access_user {


   function register_user($first_login, $first_password, $confirm_password, $first_name, $first_info, $first_email) {
      if ($this->check_new_password($first_password, $confirm_password)) {
         if (strlen($first_login) >= LOGIN_LENGTH) {
            if ($this->check_email($first_email)) {
               $this->user_email = $first_email;
               $this->user = $first_login;
               if ($this->check_user("new")) {
                  $this->the_msg = $this->messages(12);
                  return false;
               } else {
                  $sql = sprintf("INSERT INTO %s (id, login, pw, real_name, extra_info, email, access_level, active) VALUES (NULL, %s, %s, %s, %s, %s, %d, 'n')",
                     $this->table_name,
                     $this->ins_string($first_login),
                     $this->ins_string(md5($first_password)),
                     $this->ins_string($first_name),
                     $this->ins_string($first_info),
                     $this->ins_string($this->user_email),
                     DEFAULT_ACCESS_LEVEL);
                  $ins_res = mysql_query($sql) or die(mysql_error());
                  
                     echo "databese done <br>";
                  if ($ins_res) {
                     $this->id = mysql_insert_id();
                     $this->user_pw = $first_password;
                     if (!$this->auto_activation) {
                        $subject = 39;
                        $body = 40;
                     } else {
                        $subject = 28;
                        $body = 29;
                     }
                     if ($this->send_mail($this->user_email, $body, $subject)) {
                        $this->the_msg = $this->messages(13);
                        return true;
                     } else {
                        mysql_query(sprintf("DELETE FROM %s WHERE id = %s", $this->table_name, $this->id));
                        $this->the_msg = $this->messages(14);
                        return false;
                     }
                  } else {
                     $this->the_msg = $this->messages(15);
                     return false;
                  }
               }
            } else {
               $this->the_msg = $this->messages(16);
               return false;
            }
         } else {
            $this->the_msg = $this->messages(17);
            return false;
         }
      }
   }
}

$new_member = new myRegister;
//$new_member->language = "nl"; // use this selector to get messages in other languages

if (isset($_POST['Submit'])) {
   if ($new_member->register_user($_POST['login'], $_POST['password'], $_POST['confirm'], $_POST['name'], $_POST['info'], $_POST['email']))
      {
            echo "redirect wordt gestart <br>";
            header("Location: ". $_SERVER['PHP_SELF']. "/register_success.php");   
      }
}
$error = $new_member->the_msg; // error message
echo "hier komt the_msg: " .$new_member->the_msg;
?>
« Last Edit: Aug 25, 2006, 06:47:38 PM by scooter »
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6274
38470 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Aug 25, 2006, 07:19:46 PM »

its not allowed to output data before sending a header you did this twice...

I debug this kind of things without sending a header and only if everthing is working I send the header.


Last blog : 4th of July Lottery from TemplateMonster.com
What a dork
*
Posts: 17
110 credits
Members referred : 0


« Reply #5 on: Aug 29, 2006, 02:39:49 AM »

Thanks Olaf. It took a few days, but I got it all nipped now. No output before header(). This was a good lesson on an interesting subject!!!
What a dork
*
Posts: 17
110 credits
Members referred : 0


« Reply #6 on: Dec 09, 2006, 06:26:39 AM »

Step 1: I have an input form on page 1 (asks for only an e-mail address). I use this e-mail address to lookup  the username, password and redirect to page 2.
<form name="form1" method="post" action=<?PHP echo "/page_1/"; ?>>
<label for="login">E-mail:</label>
<input type="text" name="login" size="30" value="<?php echo (isset($_POST['login'])) ? $_POST['login'] : $my_access->user; ?>">
<input type="submit" name="Submit" value="Login">
</form>
Step 2: On page 2 the user needs only to click on a second Submit-button (see below) with two hidden form-fields. These hidden fields already contain the username, password (from Step 1) so the user can automatically login to the external web-application (for example http://url.web-application.net Visit through proxy).
<form name="form1" method="post" action="http://url.web-application.net Visit through proxy"
<input type="hidden" name="login" size="30" value="<?php echo (isset($_POST['login'])) ? $_POST['login'] : $my_access->user; ?>">
<input type="hidden" name="password" size="8" value="<?php echo (isset($_POST['password'])) ? $_POST['password'] : $my_access->user_pw; ?>">
<input type="submit" value="Begin web-application" >
</form>

Above procedure is a way to automatically login to an external web-application, with only your e-mail address and it works fine.

My question is how can I let the user: enter an e-mail address(1), lookup the username password in a database(2) and send them to the external web-application where to user is logged-in automatiacally(3) all on one page. I tried it with methodes like:
$_POST['login'] = $login;
$_POST['password'] = $password;
heaser("location: ")

But I had no luck yet. Hope you have an idea?
« Last Edit: Dec 09, 2006, 06:29:05 AM by scooter »
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6274
38470 credits
Members referred : 374


It's time to use PHP5!


« Reply #7 on: Dec 09, 2006, 10:01:05 AM »

Quote
My question is how can I let the user: enter an e-mail address(1), lookup the username password in a database(2) and send them to the external web-application where to user is logged-in automatiacally(3) all on one page. I tried it with methodes like:
$_POST['login'] = $login;
$_POST['password'] = $password;
heaser("location: ")

But I had no luck yet. Hope you have an idea?

I think that can be done cURL, but I'm sure that this more difficult than what you have done until now.
btw. posting the login and password to a form is very unsafe...


Last blog : 4th of July Lottery from TemplateMonster.com
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7943
40607 credits
Members referred : 3



« Reply #8 on: Dec 09, 2006, 12:24:42 PM »

I had the same problem before some time.

cURL will be difficult as implementation, and it may have some security risks - it can be buggy with this implementation.

SOAP is the best way to do that if you want a server implementation, but it will need a lot of development time.

The best and easiest way to do that, is to create a form for the user and automatically submit it with javascipt to the other site Smiley

Trial and Error my two best teachers Cool
Promote your blog for free.... Visit through proxy

Last blog : MIA - Where Nick and Tim
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=3800
Tags : html curl email Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Access_user Class (Moderator: Olaf)
Topic: redirect after succesful registration.php???
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Jul 09, 2008, 12:30:39 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 35.588
Total Topics: 7.355
Total Members: 3.661
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: komrad

26 Guests, 4 Users online :

17 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.