0

my problem is following:

I am using this code to pass a value to a different file called "benutzerstart.php". Debugging through the jquery shows, that the value in "var beta" is correct.

I do get a problem with getting the value to a PHP variable.

The error code is : "Notice: Undefined index: param in C:\xampp\htdocs\KVP\benutzerstart.php on line 76"

Referring to the error code my suggestion is that the passed value is not really passed to the php file.

JQuery code:

<script>
          $('#form').submit(function() {
            var arrayFromPHP = <?php echo json_encode($Email) ?>;          
            var newMail = $.trim($('#Email').val())     
            var pw1 = $.trim($('#Password').val()) 
            var mailVorhanden = false;
            var pwRichtig = false;
            var idVondemShit = -1;
            var tempindex = -1;

            for ( var i = 0; i < arrayFromPHP.length; i++ ) {
         //   $.each(arrayFromPHP, function (i, val) {
            if(newMail === arrayFromPHP[i].Email ){
              mailVorhanden = true;
              tempindex = i;
              break;
           } 
          };
              if (mailVorhanden === true)
              {
               if(pw1 === arrayFromPHP[tempindex].pw) 
               {
                idVondemShit = arrayFromPHP[tempindex].idName;
                pwRichtig = true;
                 if(arrayFromPHP[tempindex].mode === "1")
               {  
                location.href='startseite.html';
                pwRichtig = false;
               }  
               }
               else
               {
                alert('Passwort oder Nutzername falsch.');
               }
              }
              else{
               alert('Passwort oder Nutzername falsch.');
              }
              var beta = arrayFromPHP[tempindex].idName
              $.ajax({
                url: 'benutzerstart.php',
                data: {'param' : 'beta'},
              });
              return pwRichtig  
        });    
        </script>

PHP code from "benutzerstart.php":

<?php
  // Collect data
  mysql_connect("localhost", "root" , "Floradix94");
  mysql_select_db("hallo");
  $tstID =  $_GET['param'];
  $sql= "SELECT         erfassung.Verbesserungsvorschlag,erfassung.megusta,login.Email,erfassung.id,erfassung.Betre    ff FROM (erfassung INNER JOIN login ON erfassung.loginid=login.loginid)"; 
  $query=mysql_query($sql) or die (mysql_error());
  while($row = mysql_fetch_assoc($query)) {
   $modals[] = array(
  'id' => 'modal' . $row['id'],
  'href' => '#modal' . $row['id'],
  'FormDoneId' => $row['id'] . 'FormDoneId',
  'Email' =>$row['Email'],
  'Verbesserungsvorschlag' => $row['Verbesserungsvorschlag'],
  'megusta' => $row['megusta'],
  'betreff' => $row['Betreff'],
);

 }
  ?>

Anyone got an idea?

1 Answer 1

2

Change this

data: {'param' : 'beta'},

To

data: {param : 'beta'},
Sign up to request clarification or add additional context in comments.

7 Comments

Hello Olvier, I should've said that I've tested different possibilities before, including yours. Just tried it again and I recieve the same error.
Can you check in a developer console the request sent ? You can access it with F12 shortcut on all browsers. For Chrome, watch in the Network tab : click on the request, and look at parameters in "Headers" tab to be sure param is well given. Check also that the request use GET method.
Also, PHP Side, you can use var_dump to check $_GET array. You can use $_REQUEST array to get the param value with both GET and POST methods.
Hey, I have checked the Network tab and this is what I get. imgur.com/r3frLmo "Anfrage" means "Request" in English.
Why is there two request here ? The first is OK : uses GET and send param parameter. The second is POST and there's nothing in it.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.