Results 1 to 8 of 8

Thread: PHP can't detect my html form

  1. #1
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default PHP can't detect my html form

    Here is my form:

    PHP Code:
    <form action='$conn' method='POST'>
    <
    input type='image' src='../images/minus.png' name='no' width='13' height='13'/> <img src='../images/stars.jpg' width='$star_wid' height='10' border='0'/> <input type='image' src='../images/plus.jpeg' name='yes' width='13' height='13'/>
    </
    form
    My php lines to detect button are:
    PHP Code:
    if(isset($_POST['no'])) {working 1 system
    if(isset(
    $_POST['yes'])) {working 2 system

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    your form action needs to be the location of the php script that processes the form.

    Are you trying to dynamically insert a URL for your action? e.g.,
    PHP Code:
    $conn "/url/to/script.php"
    ?

    If so, you need to echo the variable within php tags (placing the variable directly into your html won't work). Try like this:
    PHP Code:
    <?php
    $conn 
    "/url/to/script.php";
    ?>
    <form action='<?php echo $conn?>' method='POST'>
       <input type='image' src='../images/minus.png' name='no' width='13' height='13'/>
       <img src='../images/stars.jpg' width='$star_wid' height='10' border='0'/> 
       <input type='image' src='../images/plus.jpeg' name='yes' width='13' height='13'/>
    </form>

  3. #3
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    it is... $conn is url detected by the script.

    PHP Code:
    function curPageURL() {
     
    $pageURL 'http';
     if (
    $_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
     
    $pageURL .= "://";
     if (
    $_SERVER["SERVER_PORT"] != "80") {
      
    $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
     } else {
      
    $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
     }
     return 
    $pageURL;
    }
    $conn curPageURL(); 

  4. #4
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    or I cant use this url?

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Why would you not just use a relative location? That looks like a lot of extra work. Regardless, if that generates the right url then you still need to use echo and not just $conn.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    because my url is like:

    PHP Code:
    http://swat.xz.lt/redirect_upload/darbai.php?id1=1&id2=0&id3=1&id4=0 
    and every id generates itself with the page. (changes) So, if someone submits button, he will be in the same page.

  7. #7
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    yeah, you just need to echo your variable inside php tags. html won't parse php variables.

    You could also simply use
    PHP Code:
    <?php echo $_SERVER['PHP_SELF']; ?>
    if the processing page is the current page.

  8. #8
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default

    but I faced problem with this too:

    my form is variable

    PHP Code:
    $reitingas "
    <form action='
    $conn' method='POST'>
    <input type='image' src='../images/minus.png' name='no' width='13' height='13'/> <img src='../images/stars.jpg' width='
    $star_wid' height='10' border='0'/> <input type='image' src='../images/plus.jpeg' name='yes' width='13' height='13'/>
    </form>
    "

    Sorry, that I didnt post all my script, but that is why i use $conn

Bookmarks

Posting Permissions

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