简体   繁体   English

注册成功后,将用户重定向到索引页面并显示弹出窗口

[英]After successful registration redirect user to index page and display popup

    if (isset($_GET['success']) && empty ($_GET['success'])) {
            echo 'Thank you for registering your service with us!';
            } else {

    //if no errors register user
    if (empty($_POST) === false && empty($errors) === true) {

        $daysavailable='';
        foreach ($_POST['DaysAvailable'] as $value)
        {

        $daysavailable .=$value." ";

        }

        //$test = "Monday, Tuesday";
        $register_info= array (
            'MemberID'  => $_POST['MemberID'],
            'OddJobName'    => $_POST['OddJobName'],
            'Description'   => $_POST['Description'],
            'DaysAvailable' => $daysavailable,
            );
        register_job($register_info);
        if(success){
        echo"<script type=\"text/javascript\">".
            "alert('success');".
            "</script>";
        exit ();
    } else if (empty($errors) === false){
        //otherwise output errors
        echo output_errors($errors);
    }
    }

Looking at previous posts I changed my code to add: 查看以前的帖子我改变了我的代码添加:

  if(success){ //ADDED CODE
            echo"<script type=\"text/javascript\">".
                "alert('success');".
                "</script>";

Full code: 完整代码:

      if (isset($_GET['success']) && empty ($_GET['success'])) {
            echo 'Thank you for registering your service with us!';
            } else {
    //if no errors register user
    if (empty($_POST) === false && empty($errors) === true) {

        $daysavailable='';
        foreach ($_POST['DaysAvailable'] as $value)
        {

        $daysavailable .=$value." ";

        }


        $register_info= array (
            'MemberID'  => $_POST['MemberID'],
            'OddJobName'    => $_POST['OddJobName'],
            'Description'   => $_POST['Description'],
            'DaysAvailable' => $daysavailable,
            );
        register_job($register_info);

        if(success){ //ADDED CODE
        echo"<script type=\"text/javascript\">".
            "alert('success');".
            "</script>";

        exit ();
    } else if (empty($errors) === false){
        //otherwise output errors
        echo output_errors($errors);
    }
    }

Now I get a pop up, but on the same page and 'success' is an undefined consent. 现在我弹出一个,但在同一页面上,“成功”是一个未定义的同意。

What I want to happen is that when the user registers successfully they are redirected to index.php and when this page opens I need a pop up to display telling the user they have registered successfully. 我想要发生的是,当用户注册成功时,他们被重定向到index.php,当这个页面打开时,我需要弹出一个显示告诉用户他们已成功注册的用户。

I'm not great with PHP (thats probably clear from the above) so any help would be appreciated! 我对PHP不太好(这可能从上面清楚)所以任何帮助将不胜感激!

In your registration page do 在你的注册页面做

  if ($success) {
    header('Location: index.php?success=true');
  }

In your index.php 在你的index.php中

 if ($_GET['success']) {
      echo"<script type=\"text/javascript\">".
            "alert('success');".
            "</script>";
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM