www.webdeveloper.com
Results 1 to 3 of 3

Thread: $_Request does not seem to work *php noob here*

  1. #1
    Join Date
    Oct 2012
    Posts
    1

    $_Request does not seem to work *php noob here*

    Hello, I am struggling with this piece of code...
    I just want to do a simple html post to PHP with jQuery

    HTML Code:
    <form id="login2" name="login" method="post" action="../Main/profile.php" enctype="multipart/form-data" >
    	<h2>Login</h2> </br>
    	   <table>
    	<tr><td>Username: </td><td><input type="text" placeholder="Enter username" name="uUser"  id="uUser1" class="formInput"></input><td></tr>
    	<tr><td>Password:  </td><td><input type="password" placeholder="Enter password" name="uPass" id="uPass1" class="formInput"></input><td></tr>
    				   </table>
    				</br>				
    </div>
    			</form>
    JQuery :
    Code:
    $(document).ready(function()
     {
      $("#login2").submit();
     }
    profile.php
    PHP Code:
    <?php
            
    if($uUser = isset($_POST['login2']))
             {
               echo 
    "set";
             }
             else
              echo 
    "not set";
                    
            echo 
    $uUser;
               
    ?>
    "not set" is displayed while I want $uUser to display

    sorry my indentation is weird

    Any help will be appreciated

  2. #2
    Join Date
    Oct 2012
    Posts
    4
    "login2" doesnt exist.

    $_POST uses the NAME attributes from your form. So you'd use uUser or uPass.

    To see what gets passed with your post you can do :
    echo "<pre>";
    print_r($_POST);
    echo "</pre>";

  3. #3
    Join Date
    Aug 2012
    Posts
    155
    You have a few problems that I can see

    1. As the previous poster said you don't have a field with the name Login2 in your form so there will be no post data sent through for $_POST['Login2'] as it doesn't exist (that is the id of your form)

    2. Why do you want to use jQuery - what you have is a simple login form and I can't see anywhere where you would need to use jQuery to submit the form (unless some of your code is missing) and I can't even see a submit button so not sure how you are even submitting your data.

    3. You have the type of the form set to enctype="multipart/form-data" which is not necessary as this is only required when you are uploading a file through the form submittal.

    All you need is the form you have and then on the receiving page, change your script to:

    PHP Code:
    if (isset($_POST['uUser'])) 
             { 
               echo 
    $_POST['uUser']; 
             } 
             else {
              echo 
    "not set"// Not sure what this is actually for so may not even be required
             


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles