Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Im having some trouble implementing info into a database

I got the line

PHP
$mxitid = $_SERVER["HTTP_X_MXIT_USERID_R"];


Which I'm importing to my database via


PHP
$sql = "INSERT INTO ".$dbTable." (StringyChat_ip,StringyChat_name,StringyChat_message,StringyChat_time,mxit_id) VALUES (\"$ip\",\"$name\",\"$message\",$post_time,$mxitid)";
                  $result = mysql_query($sql);


well its working perfectly, but the problem I'm experiencing is that if my value
PHP
$_SERVER["HTTP_X_MXIT_USERID_R"]
cannot be retrieved I can't insert any info to my database.

the
PHP
$_SERVER["HTTP_X_MXIT_USERID_R"]
is being used via a specific platform called mxit, so if I use any other platform it don't work. Is there maybe a way to change the line
PHP
$mxitid = $_SERVER["HTTP_X_MXIT_USERID_R"];
to a function if the info couldn't be retrieved to insert another default value like ADMIN rather in the place of it?
Posted
Updated 31-Aug-14 6:16am
v2
Comments
Mohibur Rashid 31-Aug-14 19:15pm    
the header is set by the client application. Your MXIT was the responsible to do the job. I am not sure if it is possible to change the header on request. You can add the Id with your data posting. or you can set the value through PHP or Javascript. in PHP header("HTTP_X_MIXIT_USERID_R : someid"); is suppose to work. with javascript follow this link, http://stackoverflow.com/questions/11214718/is-it-possible-to-alter-http-requests-header-using-javascript
it may help

1 solution

PHP
$mxitid = $_SERVER["HTTP_X_MXIT_USERID_R"];

if(!isset($mxitid))
{
    $mxitid = "DEFAULT";
}


Did the job perfectly...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900