Jump to content

php new bie

Members
  • Posts

    31
  • Joined

  • Last visited

Everything posted by php new bie

  1. AbraCadaver , it works , Thank you very very much
  2. hello, I write a script using http_post_fields , the script work on my local host using easyphp .. When I upload it to my host service , it gives me an error to undefined function http_post_fields .. OK I know the problem ! the pecl_http extension not installed , So I contact my service provider and there is no replay .. my Q : any alternative function or code similar to http_post_fields thanks
  3. hello, The problem in short .. I googled and read almost all phpfreaks help threads and try manually evreything and I failed ! I have 2 sites A and B , What i want to make user login from site A into B using curl and thats OK. After logining in the page redirect the user to next page depending on the session generated by site b like this ASP.NET_SessionId=XXXXXXXXXXXX; path=/; HttpOnly now ! it says your session has been expired -> Re-login what I do is : function login($username,$pass){ /* STEP 1. let’s create a cookie file */ $cookie_jar = tempnam('./ses/','cookie'); /* STEP 2. visit the homepage to set the cookie properly */ $ch = curl_init ("http://siteB"); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie_jar); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); $source = curl_exec ($ch); $data = array('Username' => $username, 'Password' => $pass); $ch = curl_init ("http://SiteB_POST_PAGE"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt ($ch, CURLOPT_COOKIEFILE, "$cookie_jar"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $source = curl_exec ($ch); curl_close($ch); return $source; } echo login("name","pass"); I go to session folder and i see the generated file,every time i refresh the page a new file.tmp created with content : # Netscape HTTP Cookie File # http://curlm.haxx.se/rfc/cookie_spec.html # This file was generated by libcurl! Edit at your own risk. siteB FALSE / FALSE 0 ASP.NET_SessionId XXXXXXXXXXXXXXX . thats mean that cookies are properly stored but when login the login success and upon redirecting it says session has been expired, How can i save session to be used again and again !
  4. Maq, I used Nightslyr's suggestion and it works like a knife in butter xD thank you again and thanks to all. by the way this is a Demo not the real script because the real one is Messy and I need this function in the code so I write this simple one to be more easier to all to understand the problem exactly
  5. thanks, when I place $rand in switch function all done .. but what about this if I want the $match in switch function .. is that logically error ? !
  6. This code makes me crazy ??? why the numbers won't work properly when matched !! <?php $rand = rand(1,5); $num = array(0,1,2,3,4,5); $match = "" ; echo "<PRE>"; print_r($num); echo "</PRE>"; echo "rand = ". $rand . "<br />"; switch ($match){ case ($rand == $num['1'] ): $match = "PRE"; echo $match; break; case ($rand == $num['2']): $match = "1st"; echo $match; break; case ($rand == $num['3'] ): $match = "2nd"; echo $match; break; case ($rand == $num['4']): $match = "3rd"; echo $match; break; case ($rand == $num['5']): $match = "4th"; echo $match; break; default : $match = "NAH!"; break; } ?>
  7. hi, It may be a noob Q, but I'll appreciate any help :-) www.example.com is a remote host that uses ASP applications and java scripts and window's frames. So I need to get some data from these systems using file_get_contents function but the site depends on session . Any way to make a connection to the remote host and retrieve the generated session and use it through my code, then close the connection when the page completely loaded and if reloaded .. the cycle repeated by getting the new session and so on !
  8. yes ken , sure updating site policy will be changed thats if i found any solution. lol, i don't say two ppl using the same pc is abuse.I said based on the harm and abuse they do , if i start new topic in any boatd and have 2 accounts and then start to use the both in same thread and replying on my self and some of that infant mind do !! banning based on that you're sure that these accounts from the same PC and have some kind of similar pc info. and about schools , sure any webmaster will take that in his consideration
  9. thats based on abuse, i just want to discover that so i start this topic then baning their accounts based on the harm or abuse they do.
  10. simple modem restart and user agent switcher plugin in FF can override this . yes i googled and got that php is a server side lang .. Nope! PHP resides in the server so even if you could get those, you'll be getting the specs of your server hard drive, MAC address etc. If you want that to grab the user's computer specs, I find that very invasive. I probably would avoid your site. ken, any website is based on TRUST between the web application and returning visitors .. some ppl you need to ban them and they are just annoying u change their ips .. user agents have tons of membership ? so what can you do if you were me ! i need to improve my system to raise the security and privacy and ensure there is only one member has one account !
  11. i don't need a hard serial number as it.. i need something specific and unique for each user other than supplied by $_SERVER variable so what can i do with this ? the value will be encrypted and placen in cookies to be checked each visit also to detect cheating users ..
  12. i'm sorry if i don't clarify what i want .. so, i know this variable and use it ... and get information ... this step DONE ! now any other methods to get information like .. hard drive serial .. MAC address , computer name .. etc (another type of information not in the variable $_SERVER ) .. something more specific and unique to each user
  13. thanks, i know this .. i just ask if there is any other php methods to gather information like this to get more info
  14. hello, a noob Q but i appreciate anyone help me i wondered which info can PHP get from user .. i figured out those of global variable $_SERVER like .. IP adress , Remote host name ,useragent .. etc so what can i get also from php if i want to improve the log and cookie system of any web application thanks
  15. I am just showing the username:email fields into a textarea output , the problem is formating the result through the textarea to make every row in new line . without textarea i use echo "<PRE>"; echo $result ; echo "</PRE>"; or just echo $result . "<br / >"; and that works fine . but when the result appears through <textarea> it is not in a neat format .
  16. hello , i don't know if it is mysql or php or html issue , i have php script that do mysql Query and post the result into textarea . so when i make connection to DB and Query username and email in format $query = "SELECT * FROM USERINFO "; and fetching the row into the appropriate columns name , the output in the textarea field appears with NO new line "\n". $result = $row['username'] .";". $row['email'] ; Then : echo $result."\n"; output like this : --- textarea --- username1:email1username2:email2 ...etc --- / textarea --- while i need : --- textarea --- username1:email1 username2:email2 --- / textarea --- then i try : $result = $row['username'] .";". $row['email'] ."\n" ; then echo the result same problem no break .. any help ?
  17. i test the code and find this error : Notice: Use of undefined constant localhost - , so you need to add single quote 'localhost' and without while loop it just show the first record with desired columns in the selected TABLE and neglect the rest ! -php new bie
  18. I edit some of your code , This one below list two columns in a table with format Data1:data2 <html> <head> <title>PHP Test</title> </head> <body> <?php echo "<b><center>Database Output</center></b><br><br>"; $username="root"; $password="xxxx"; $database="test2"; mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM fr_users"; $result=mysql_query($query); //$num=mysql_numrows($result); mysql_close(); //$i=0; while ($row = mysql_fetch_array($result)) { //$field1-name=mysql_result($result,$i,"login"); //$field2-name=mysql_result($result,$i,"alias"); echo $row['login'] . ":" . $row['alias']."<br />"; // desired columns names } ?> </body> </html> Appreciate any help. Thank You. I am sure this is very easy to do.
  19. ok , i will try . Thanks Third_Degree
  20. this code get the no. of results obtained by using google search the 2nd part inserts them to DB , which works on the local host [server or PC] , some servers show me fatal error due to max_execution_time of the function 'file_get_contents' ,BTW 'set_time_limit' NOT work when safe mode ON ? <html> <center> <form method="POST" action="<?php $_SERVER['PHP_SELF']; ?>"> <br> Get google page results for the term word ? <br> <br> <input type="text" name="x"> <br> <br> <input type="submit" name="submit" value="Get results now!"> </form> </center> </html> <?php if (isset($_POST['x'])){ $x=$_POST['x']; } if(isset($x)){ $n = str_replace(" ","+",$x); $q=file_get_contents("http://www.google.com/search?hl=en&q=$n&btnG=Search"); $sp = "about <b>(.*)<\/b> for"; $num = ereg($sp,$q,$reg); if ($num) { echo "<center><br /><font color=green" . substr($reg[0] , 5 , -3) . "</font></center>" ; } else { echo "<center>No result Founded !</center>"; } } ?>
  21. i mean how to prevent the Fatal error and make the script complete loading <=- this is the main idea . in my case : 1st of the code make external connections , which my be down or slow so [fatal error appears and avoid the next block of code which work fine] . the bottom of code works fine localy , so no problem with max-execution_time . thank you all of you for quick reply
  22. hello , if i have acode like this : <?php block of code depends [if this got max execution time Fatal Error obtained preventing the rest of script to load , so my Question how can i make conditional statement to till if max execution time exceeded just complete the rest ?] ////////// other block of code ?> thanks
  23. thats mean that after the double // avoid any spaces and both char '<' , '>' thank you very much for your help , i stuck with that about 1 hr to understand
  24. can some one please explain this in more info : //[^<>[:space:]]+ double slashes are for url http:// and i know that [[:space::]] for any white or blank charachter but i don't get what that ^<> thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.