dongzaobei0942
2013-03-24 16:45
浏览 56
已采纳

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

    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.

I'm not great with PHP (thats probably clear from the above) so any help would be appreciated!

1条回答 默认 最新

相关推荐 更多相似问题