passing variables to new window in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • runway27
    Banned
    New Member
    • Sep 2007
    • 54

    passing variables to new window in php

    1.

    i have a self submitting form using POST
    <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST" id="test2" name="registrat ionform">

    i am not using any javascript assuming javascript is turned off in a users browser.

    i have a feature where in a user can click on an image to find out if a username is available or not. using javascript i am able to capture the value entered, pass the value entered by the user and open a new window and display a message with a php file if the username is available or not

    however since i am not using javascript i used the following code to call the same php file which checks for the user name,

    <a href="checkuser name.php?userna meis="<?php echo($username) ; ?> target="_blank" > <img src="image.jpg" > </a>

    however i am not able to pass the value of the username entered in the textfield by the user.

    code in checkusername.p hp is

    $username = $_GET["usernameis "]; and the remaining code to connect to database and display a message.

    how can i pass the value entered in the textfield to checkusername.p hp when the image is clicked.

    textfield is defined as follows = <input name="username" type="text" value="<?php echo($username) ; ?>" />


    2.
    i need to validate a password which can consist of both letters and numbers and should be between 5 to 10 characters only.

    how can i rewrite the following preg_match to specify the condition of 5 to 10 characters only as presently it is not working

    as i seem to be missing something in the syntax.

    if($password == "" || !preg_match('/^[a-zA-Z0-9]{\(5)$|^\(10)}+ $/', $password) )

    please advice.

    thanks.
  • zorgi
    Recognized Expert Contributor
    • Mar 2008
    • 431

    #2
    For No1

    Try changing:

    [HTML]<a href="checkuser name.php?userna meis="<?php echo($username) ; ?> target="_blank" > [/HTML]


    into


    [HTML]<a href="checkuser name.php?userna meis=<?php echo($username) ; ?>" target="_blank" >[/HTML]

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      No1
      Why dont you use a form with an image as the submit button?
      [html]
      <form name="someForm" action="somephp page.php" method="post">
      <input type="text" name="username" />
      <input type="image" src="locationOf Image.jpg" height=".." width=".." name="submit" />
      </form>
      [/html]

      No2
      Try:
      [php]
      if($password == "" || !preg_match('/^[a-zA-Z0-9]{5,10}+$/', $password) )
      [/php]

      Comment

      Working...