How should i capture an id

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • How should i capture an id

    Hallo,

    I display profiles from a table on a page.Each profile has an id and each profile can also be contacted with the link "Contact this person".
    When somebody click on this link a new window(contact_form.php) is opened, where the user can enter his name, email and description.When the user submits this form, I save all the information into a table.
    I have done upto here and everything is working fine.

    Now, my question is How can I capture the profile id?? , say if the user has contacted the first profile, i would like to store this profile id no.

    You can view my example page HERE

    I only see the problem is that the profile id is not being sent properly, How can i do this one??

    ess.php is the form which displays all the profiles and this part of the code is the one which is troubling me.
    PHP-Code:
    // I think here i need to add id field and this id has to be passed to contact_form.php as well as to mail.php, right??How should i?
    echo '<a href="javascript:';
    echo 
    'openWindow(\'contact_form.php\',\'\',\'toolbar=no,status=no\',\'724\',\'470\',\'true\');">Contact the Person</a>'
    and in contact_form.php , i have this code:
    PHP-Code:
    <form  name=form method="post" action="email.php">
    and also 
    <td width="100%"><input type=button value="Submit" onclick="verify();">
    </td>
     <input type="hidden" name="id" value="<?=$HTTP_GET_VARS['id']?>">
    and now email.php is the one which executes my sql query and it looks like:
    PHP-Code:
    $query "insert into $mytable (name, email, text, contacted_id) values ('$name','$email','$description','$id')";
    $result mysql_query($query); 
    Sorry for the lengthy post, just trying to explain it clearly so that somebody would fix it easily.

    Thanks
    Happiness is a state of mind.
    Change your mind and be happy!

  • #2
    should it be like this:

    PHP-Code:
    echo 'openWindow('contact_form.php?id=$row[id]','','toolbar=no,status=no','724','470','true');">Contact the Person</a>'

    Kommentar


    • #3
      Hallo Tobiaz,

      Sorry thats does'nt even help me.The profile id does'nt get inserted.Do you want me to post the code of all the 3 forms??I dont have any problems with my forms other than this id.

      Thanks
      Happiness is a state of mind.
      Change your mind and be happy!

      Kommentar


      • #4
        i think, the problem is, that the id isnt available at your contactform. and for that you have to submit it in the URL. like i posted.

        NOTE: You have to edit the line i postet, because i can't know how your variable with the id is called.

        so please change it to the right name, or perhaps post the code of the first (list) page

        Kommentar


        • #5
          Tobiaz,

          Heres the code of the page (ess.php) which displays all the profiles:
          PHP-Code:
          <html> 
          <head>
          <link REL=stylesheet href="mystyle.css" TYPE="text/css">
          <script type="text/javascript">

          function open_phone_number_window(number)
          {
              window_html_code = "<html>";
              window_html_code += "<head><title>Phone number</title></head>";
              window_html_code += "<body>";
              window_html_code += "<table width=\"100%\" height=\"100%\">";
              window_html_code += "<tr><td valign=\"middle\" align=\"center\">";
              window_html_code += number;
              window_html_code += "<br>";
              window_html_code += "<a href=\"javascript:window.close();\">close window</a>";
              window_html_code += "</td></tr></table>";
              window_html_code += "</body>";
              window_html_code += "</html>";
              
              win = window.open("","win","top=100,left=200,width=225,height=100");
              win.document.write(window_html_code);
          }

          </script>

          <script type="text/javascript"> 

          function openWindow(theURL,winName,features, myWidth, myHeight, isCenter) { 
          if(window.screen)if(isCenter)if(isCenter=="true"){ 
          var myLeft = (screen.width-myWidth)/2; 
          var myTop = (screen.height-myHeight)/2; 
          features+=(features!='')?',':''; 
          features+=',left='+myLeft+',top='+myTop; 

          window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight); 


          </script> 

          </head>

          <body bgcolor="#FFFFCC"> 
          <?php 

          // Lets create MySQL connection 

          // Lets select the database 

          // Lets select the record fields from our database table and check for results 

              
          $query="SELECT introtext,zipcode,image,telephone,description FROM tbl_personals ORDER BY id"

              
          $numresults=mysql_query($query,$connection); 
              
          $numrows=mysql_num_rows($numresults); 

          // get results

            
          $result mysql_query($query) or die("Couldn't execute query");

          // We carry out the table population using a 'while' loop 

          while ($row=mysql_fetch_array($result)) 

          $var_7=$row["id"];
          $var_1=$row["introtext"]; 
          $var_2=$row["zipcode"]; 
          $var_3=$row["image"]; 
          $var_4=$row["telephone"]; 
          $var_6=$row["description"]; 

          // Display the results 

          echo '<table width="80%">';
          echo 
          '<tr>';
          echo 
          '<td width="100%" colspan="2"><b>'.$var_1.'</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          '
          .$var_7.'';
          echo 
          '</td> 
            </tr>'
          ;
          echo 
          '<tr>
              <td width="50%">Zip Code:'
          .$var_2.'</td>
              <td width="50%" rowspan="4" bordercolorlight="#C0C0C0" bordercolordark="#C0C0C0">'
          .$var_6.'</td>
            </tr>'
          ;
          echo 
          '<tr>
              <td width="50%"><img src="'
          .$var_3.'"></td>
                </tr>'
          ;
          echo 
          '<tr>';
          echo 
          '<td width="50%">';
          echo 
          '<a href="javascript:';
          echo 
          'open_phone_number_window(\''.$row['telephone'].'\');">Telephone number</a>';
          echo 
          '</td>';
          echo 
          '</tr>';
          echo 
          '<tr>';
          echo 
          '<td width="50%">';
          echo 
          '<a href="javascript:';
          echo 
          'openWindow(\'contact_form.php?id=$row[id]\',\'\',\'toolbar=no,status=no\',\'724\',\'470\',\'true\');">Contact the Person</a>'
          echo 
          '</tr>';
          echo 
          '</table>
          &nbsp'
          ;



          //We close the MySQL connection 

              
          mysql_close($connection); 

          ?> 

          </TABLE> 
          </body> 
          </html>
          Happiness is a state of mind.
          Change your mind and be happy!

          Kommentar


          • #6
            you should use the right queries:

            $query="SELECT introtext,zipcode,image,telephone,description FROM tbl_personals ORDER BY id";


            schould be

            $query="SELECT id,introtext,zipcode,image,telephone,description FROM tbl_personals ORDER BY id";

            Kommentar


            • #7
              Sorry Tobiaz.My code was messed up and i did something wrong.

              well, mysql query in the code contains id field actually.That has'nt even helped me though:-(

              Any other ideas??

              Thanks for your time.
              Happiness is a state of mind.
              Change your mind and be happy!

              Kommentar


              • #8
                try to use $var_6 in the url.

                btw. please output the ID in your onlineversion whith each entry, please.

                Kommentar


                • #9
                  Tobiaz,
                  Sounds really weird.what-ever changes i do, it does'nt help me, gosh!!

                  btw. please output the ID in your onlineversion whith each entry, please.
                  I dont get you, my on-line version is the latest code i have.I dont think $var_6 is going to help me, because that is nothing related with my id field.or do you mean something like this:
                  PHP-Code:
                  echo 'openWindow(\'contact_form.php?id=$var_7\',\'\',\'toolbar=no,status=no\',\'724\',\'470\',\'true\');">Contact the Person</a>'
                  Thanks once again
                  Happiness is a state of mind.
                  Change your mind and be happy!

                  Kommentar


                  • #10
                    as you know, this is an entry;
                    BrownEyedGrrrl 1
                    Zip Code:67663

                    Hello to all ... to you soon

                    Telephone number
                    Contact the Person
                    i think the 1 is from a counter?

                    so then, could you please output the ID next to the Name (Brown Eyed Gril)

                    Kommentar


                    • #11
                      oh NO, you mis-understood me.

                      BrownEyedGrrrl 1

                      1 is not from the counter.It is the id field in the table.That is the very first record.Well,I'm using this id as my profile id.

                      I hope this was a confusion right from the beginning.

                      Thanks once again.
                      Happiness is a state of mind.
                      Change your mind and be happy!

                      Kommentar


                      • #12
                        thats wunderful!!!!

                        so we have no problems anymore!

                        so i supose $var_7 is your id, as it stands in your code. did you test this, because you posted this solution some posts ago.

                        Kommentar


                        • #13
                          hmm...NO way!
                          Sounds like a nightmare for me,huh!
                          I dont see any improvements with my code.yep, this is the one which i've it :
                          PHP-Code:
                          echo 'openWindow(\'contact_form.php?id=$var_7\',\'\',\'toolbar=no,status=no\',\'724\',\'470\',\'true\');">Contact the Person</a>'
                          and dont you think when i right-click and view the source i should be able to see the id value, that is, if its first profile, i guess i should see 1.BUt, i dont see such.so, theres a problem which is killing me-I'm going blind.

                          Thanks for your valuable time.
                          Happiness is a state of mind.
                          Change your mind and be happy!

                          Kommentar


                          • #14
                            so try to use " instead of ' for the echo. because in ' no variables are parsed.

                            Kommentar


                            • #15
                              Tobiaz,

                              I cant belive!I can see the id passing out but, something strange happened.Dont you think this is the right way of coding?

                              echo '<a href="javascript:';
                              echo "openWindow('contact_form.php?id=$var_7','','toolbar=no,status=no','724','470','true');'>Contact the Person</a>";

                              If you see my on-line page, you can visualise what has happened now?

                              thanks
                              Happiness is a state of mind.
                              Change your mind and be happy!

                              Kommentar

                              Lädt...
                              X