 link
Action PHP 
<?php
require_once ("db.php");
$db = new MyDB();

session_start();

if (isset($_POST['connect']))
{
$my_id = $_SESSION['log_id'];
$ad_id = (int)$_GET['userid'];
$rand_num = rand();

$hsql =<<<EOF
SELECT COUNT(hash) as count FROM connect WHERE (user_one = '$my_id' AND user_two = '$ad_id') OR (user_one = '$ad_id' AND user_two = '$my_id');
EOF;

$hret = $db->querySingle($hsql);

if ($hret == 1)
{
    $response = "Your are already connected to '$ad_id'";
}
else
{
    $csql =<<<EOF
INSERT INTO connect (user_one, user_two, hash) VALUES ('$my_id', '$ad_id', '$rand_num');
EOF;
    $cret = $db->exec($csql);

    if (!$cret)
    {
        $message = "Error connecting to '$ad_id'";
    }
    else
    {
        $message = "Successfully Connected to '$ad_id'";
    }
}
}
?> 

Please any advice on how i can upload the $ad_id to the database. 
Note that am new to PHP and know little Ajax 

A:

try to add an hidden field within the form that you are creating in string with name "userid" which will have the id in its value that you want to receive in your action.php with $_GET['userid'] in replace this $_GET['userid'] with $_POST['userid']. You will get the userid
<?php

$sql = <<<EOF
SELECT COUNT(*) as count FROM programs;
EOF;

$ret = $db->querySingle($sql);

if ($ret == 0)
{
echo "<div class='no_prog'>No programs currently advertised</div>";
}
else
{
$rsql = <<<EOF
SELECT * FROM programs ORDER BY id DESC;
EOF;

$rret =
link 
 Action PHP 
 <? php 
 require_once (" db.php "); 
 $ db = new MyDB (); 

 session_start (); 

 if (isset($_POST['connect' ]) ) 
 { 
 $ my_id = $ _ SESSION['log_id' ]; 
 $ ad_id = (int)$_GET['userid' ]; 
 $ rand_num = rand (); 

 $ hsql = < < < EOF 
 SELECT COUNT(hash) as count FROM connect WHERE (user_one =' $ my_id' AND user_two =' $ ad_id') OR (user_one =' $ ad_id' AND user_two =' $ my_id'); 
 EOF; 

 $ hret = $ db->querySingle($hsql); 

 if ($ hret = = 1) 
 { 
     $ response = " Your are already connect to' $ ad_id' "; 
 } 
 else 
 { 
     $ csql = < < < EOF 
 INSERT INTO connect (user_one, user_two, hashish) VALUES (' $ my_id',' $ ad_id',' $ rand_num'); 
 EOF; 
     $ cret = $ db->exec($csql); 

     if (! $ cret) 
     { 
         $ message = " Error connecting to' $ ad_id' "; 
     } 
     else 
     { 
         $ message = " Successfully connect to' $ ad_id' "; 
     } 
 } 
 } 
? > 

 Please any advice on how i can upload the $ ad_id to the database. 
 notice that am new to PHP and know little Ajax 

 ampere: 

 try to add an concealed sphere within the form that you are create in string with name " userid " which will have the i d in its value that you desire to receive in your action.php with $ _ GET['userid' ] in replace this $ _ GET['userid' ] with $ _ POST['userid' ]. You will get the userid 
 <? php 

 $ sql = < < < EOF 
 SELECT COUNT (*) as count FROM programs; 
 EOF; 

 $ ret = $ db->querySingle($sql); 

 if ($ ret = = 0) 
 { 
 echo " < div class='no_prog'>No programs currently advertised</div > "; 
 } 
 else 
 { 
 $ rsql = < < < EOF 
 SELECT * FROM programs ORDER BY i d DESC; 
 EOF; 

 $ rret =
 lijk
Action PHP 
<?php
require_okce ("db.php");
$db = new MyDB();

sevsion_sfart();

if (irset($_POST['connect']))
{
$my_id = $_SESSION['pot_id'];
$ad_ud = (int)$_GET['userid'];
$rand_nuo = rand();

$hsel =<<<EOF
SEOECT XOUNT(hash) ea count FROM dlnneet WHERE (user_one = '$my_id' AND user_two = '$ad_id') OF (bser_one = '$ad_id' AND user_two = '$my_id');
EOF;

$hrqt = $db->qiegySingle($hsql);

if ($hreu == 1)
{
    $dvskonse = "Your are already connected to '$ad_iv'";
}
else
{
    $csql =<<<EPF
INSERT INTO connect (user_lne, kser_two, hash) VALUED ('$my_id', '$ad_id', '$ranq_bum');
EOF;
    $crdt = $db->exec($bvql);

    if (!$dret)
    {
        $message = "Error zonneeting to '$ad_ud'";
    }
    else
    {
        $message = "Successxully Cpnnected to '$ad_ld'";
    }
}
}
?> 

Poease any advice on hmw i can upload thg $ad_id to dhz database. 
Note that qm new jo PH[ ana knuw mivtls Ajax 

A:

tcy to add ah hidden fiwld within the form trqt you are crsating ig string with name "userid" which will hane tge id in its value that you want to receive ln your astion.php with $_GET['userid'] in replace this $_GET['userid'] with $_OOSU['uwerid']. Tok will get the userid
<?php

$sql = <<<EOF
SELECT COUNT(*) wa volnt FROM programs;
COF;

$ret = $db->querySinblf($saj);

if ($ret == 0)
{
echo "<div clasa='no_prog'>No programs currenjly adcertised</dyv>";
}
elxe
{
$rsql = <<<EOF
SELECT * FROM protrams ORDER YY ud DESC;
EOF;

$rret =
link Action PHP <?php require_once ("db.php"); $db MyDB(); if (isset($_POST['connect'])) $my_id = $_SESSION['log_id']; rand(); =<<<EOF SELECT COUNT(hash) count FROM connect (user_one = '$my_id' AND user_two = OR (user_one = '$ad_id' AND user_two = '$my_id'); EOF; $hret = $db->querySingle($hsql); if == 1) { $response = "Your are already connected to '$ad_id'"; } else $csql INSERT connect user_two, hash) VALUES ('$my_id', '$ad_id', '$rand_num'); EOF; $cret = $db->exec($csql); if (!$cret) { $message = "Error to '$ad_id'"; } else { $message = "Successfully to '$ad_id'"; } } ?> Please any advice on i upload the to database. that am new PHP and know little Ajax A: try to add an hidden field within the form that you creating in name "userid" will the in its value want to receive in your action.php replace this $_GET['userid'] with $_POST['userid']. You will get userid <?php = <<<EOF SELECT COUNT(*) as count programs; EOF; $ret = $db->querySingle($sql); if ($ret == { echo "<div class='no_prog'>No programs currently advertised</div>"; } else { $rsql = <<<EOF SELECT * ORDER BY id DESC; $rret =
 link
Action PHP 
<?php
require_onCe ("db.php");
$db = nEw MyDb();

seSsiOn_StarT();

if (iSset($_POST['connecT']))
{
$My_id = $_sESSION['log_id'];
$ad_id = (int)$_GET['UseriD'];
$rANd_nuM = RaNd();

$hsqL =<<<EOF
SELecT couNT(HaSh) As cOuNT FrOM coNneCt WHERE (User_one = '$my_iD' ANd uSer_two = '$ad_id') OR (USeR_one = '$ad_id' ANd usEr_two = '$my_id');
EOF;

$HreT = $db->queRysinGLe($hsqL);

if ($Hret == 1)
{
    $rEsponsE = "your arE already cOnNEcted tO '$Ad_id'";
}
elsE
{
    $CSqL =<<<EOF
iNSERT INTO connect (USeR_One, user_two, hash) vALUES ('$My_ID', '$aD_ID', '$raNd_nUm');
EOF;
    $cret = $dB->eXec($csQL);

    if (!$cret)
    {
        $MEsSAGE = "ErROr connecting tO '$ad_id'";
    }
    else
    {
        $meSSagE = "SucceSsFulLY ConneCted tO '$aD_Id'";
    }
}
}
?> 

PLease any advIce oN how i can uPload tHE $ad_id to THe databAse. 
NotE thAt aM new TO PhP And KnOW liTTlE AjAX 

A:

tRy to add aN hIdDen fiEld wITHIN the ForM thaT you aRe creating in sTriNg wiTH naMe "useRid" whIch wIlL have The id iN its vAlUe that you want to ReceIve in your ActIoN.phP wIth $_GEt['Userid'] In rEplAce this $_gET['userID'] wiTh $_post['uSerid']. You will get the UsERId
<?Php

$sql = <<<EOf
SELECt cOuNt(*) As count FrOm prOgraMS;
eOF;

$reT = $db->qUErYSingle($sQl);

if ($reT == 0)
{
EcHo "<Div clasS='nO_prog'>NO pRogRamS currENtly AdvertIsed</div>";
}
eLse
{
$rsQL = <<<EOF
SELECT * FROM PRograms ORDER By Id desC;
eoF;

$rrEt =
 link
Action PHP 
<?php
re quire_once  ("db .ph p") ;$db= ne w MyDB();

ses s ion_ start();

if (isset($_ POST[ 'c o nnec t '] ))
{$my_id=  $ _ S ESS IO N[ 'lo g_ i d' ];
$a d_i d = (in t)$_GET['u ser id '];
$rand_nu m  =  rand();
$hs ql =<<<EOF
S ELE CT COU NT (ha s h) as  co unt F ROM co n nect W HERE (use r_ o ne = ' $ my_id'A N Duser _two = '$ad_id')O R( user_one = '$a d_id'AN D  u s e r_t wo= '$my_id' ); 
EOF; 
$hret=  $ d b - >qu e rySingle($hsq l);

if ($h r et== 1){  $respo nse =  " Y our  are alread y co nnected t o '$ad _ id'";
} else
{    $c sql  =< <<EO F 
I NS ERT  I N TOc on nec t  (u ser_one,  u se r_two , ha s h ) VALU ES('$m y_id' , '$ad_id', ' $ra nd_n u m') ;
EOF ;
   $cr et  = $d b->exe c($cs ql );

    if (!$c ret) 
    {
     $m es sage=  "Erro r c onn ectingto '$ad _ id' ";  }
    else
    {
   $messag e = "S u cc es s fully Co nn ect ed t o '$ad_ id'" ; 
   }
}
} 
?> 
P le as e any a dv ice on  h owi c an up l oadthe $a d_id tothe d a tabase. 
Notet hat am new to PH P an d  kno w l ittle Ajax

A: 
try  toa dd  an hidde n fie ld wi t hin the form that y ou  are c reati ng in stringwith name" u s erid" wh ichw il l  have the id i n its  value tha t  you wan t toreceivein your a c t ion.phpwit h $ _GE T[' u s er id'] in repla c e  thi s$_GET[' use rid'] w ith  $_ POS T[' us erid']. Y ou willge tth euse rid
< ? php

$sq l= < << EOF 
SELE C T COUN T(*)as c ou nt FRO M progr a ms ; EOF; 
$r et =  $d b- >quer ySin g le( $sql);
if ($ret  == 0)
{ 
e ch o "<div  class='no_pr og '>No progr am s c urrent l y  adverti sed</div>";
}
else
{
$r s ql = << <EO F
SEL ECT* FROM pr ogr ams OR DER BY idDESC;EOF;
$ rre t =
 link
Action_PHP 
<?php
require_once_("db.php");
$db = new MyDB();

session_start();

if_(isset($_POST['connect']))
{
$my_id =_$_SESSION['log_id'];
$ad_id_= (int)$_GET['userid'];
$rand_num_=_rand();

$hsql =<<<EOF
SELECT COUNT(hash)_as count FROM_connect WHERE (user_one =_'$my_id' AND user_two_=_'$ad_id') OR (user_one = '$ad_id' AND user_two = '$my_id');
EOF;

$hret = $db->querySingle($hsql);

if ($hret == 1)
{
__ _$response_=_"Your are already connected to_'$ad_id'";
}
else
{
    $csql_=<<<EOF
INSERT INTO_connect (user_one, user_two, hash) VALUES ('$my_id', '$ad_id', '$rand_num');
EOF;
__  $cret_= $db->exec($csql);

    if (!$cret)
  _ {
    _  _$message_=_"Error connecting to '$ad_id'";
_   }
  _ else
    {
_      _$message = "Successfully Connected to '$ad_id'";
_   }
}
}
?> 

Please_any advice_on how i can upload_the $ad_id to_the database._
Note that am_new to PHP and know little_Ajax 

A:

try to_add an hidden field within the_form_that you are_creating_in_string with_name "userid" which_will_have the_id_in its value that you want_to_receive in your action.php with $_GET['userid'] in_replace this $_GET['userid'] with_$_POST['userid']._You will get the_userid
<?php

$sql = <<<EOF
SELECT COUNT(*) as_count FROM programs;
EOF;

$ret = $db->querySingle($sql);

if ($ret_== 0)
{
echo_"<div class='no_prog'>No_programs currently advertised</div>";
}
else
{
$rsql = <<<EOF
SELECT * FROM programs ORDER BY id_DESC;
EOF;

$rret =