Jarid
Members-
Posts
23 -
Joined
-
Last visited
Never
Everything posted by Jarid
-
I am making a simple online html editor. I wrote a php script that prints the html that you typed in the form into a .html document. The problem is that php is replacing the parentheses with / \ /\ slashes. how do i stop this? <?php $text = $_REQUEST['HTML'] ; $test= "test.html"; $fh = fopen($test, 'w') or die("can't open file"); fwrite($fh, $text); fclose($fh); ?> Thank you
-
Ahhh.... I found the problem. I messed up a line of my php. Thanks Anyway.
-
I set up a form that you can type html code into. When you click submit it sends the form data to a php script that receives the data and then prints it. Basically im trying to accomplish something similar to this http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro. I have tried to print the html code using echo and print_r. The problem is that it is not displaying correctly. For instance if i were to type in <body bgcolor="FFCC00"> Nothing would happen. Most of the html displays correctly. What is the reason behind this? Do i need to use a different command to print the form variable? Or do i need to save it as an html document then display it?
-
I need help with cURL. Submitting data like a html form.
Jarid replied to Jarid's topic in PHP Coding Help
Yep filtering out words and setting vars in javascript. -
I need help with cURL. Submitting data like a html form.
Jarid replied to Jarid's topic in PHP Coding Help
I got it working. It only took 3 languages lol. -
I need help with cURL. Submitting data like a html form.
Jarid replied to Jarid's topic in PHP Coding Help
The script expects to receive: Action Login ID In this case the action is set to modify so it also expects to receive another field with the same name as a db field. I am going to convert my variables to javascript refill the html form, and then submit it with a javascript. Thanks for the help, I'm a php noob. -
I need help with cURL. Submitting data like a html form.
Jarid replied to Jarid's topic in PHP Coding Help
Ah Crap... The cgi script is a large membership management script....... And i have no idea how it works. Even worse it does not have an error log.... Here is what im thinking about doing. Using the script above to filter the $text. Next ill fill the form with the php variables then resubmit it using javascript. Since all of this happens in a hidden i frame its not really a big deal. Do you think this will work? -
I need help with cURL. Submitting data like a html form.
Jarid replied to Jarid's topic in PHP Coding Help
i changed the html form to application/x-www-form-urlencoded no errors, but the cgi script still didn't receive and process the data. I had the cgi script export an example form for me and it had the form set to multipart/form-data... so it might require that for the modify data action. how do i change the php script for multipart/form-data? -
I need help with cURL. Submitting data like a html form.
Jarid replied to Jarid's topic in PHP Coding Help
No errors in the php... But the pm.cgi script is not receiving it correctly. both of these are working without error $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http:johnstonstudentcenter.com/members/cgi/pm.cgi'); curl_setopt($curl, CURLOPT_HEADER, true); // Make basic post request curl_setopt($curl, CURLOPT_POST, true); // Set your post data $post_data['action'] = 'modified'; $post_data['login'] = '$login'; $post_data['ID'] = '$ID'; $post_data['Unused10'] = '$text'; $post_data['submit'] = ' Update '; curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_exec($curl); curl_close($curl); ?> and $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http:johnstonstudentcenter.com/members/cgi/pm.cgi'); curl_setopt($curl, CURLOPT_HEADER, true); // Make basic post request curl_setopt($curl, CURLOPT_POST, true); // Set your post data $data = array( 'action' => 'modified', 'login' => '$login', 'ID' => '$ID', 'Unused10' => '$text', 'submit' => ' Update ' ); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_exec($curl); curl_close($curl); ?> here is the original html form. <form action=filter.php method=post ENCTYPE="multipart/form-data" target="_blank"> <input type=hidden name=action value=modified> <input type=hidden name=login value="%%login%%"> <input type=hidden name=ID value="%%ID%%"> <textarea cols=28 rows=4 name=Unused10 MAXLENGTH="500">%%Unused10%%</textarea> <input type=submit name=submit value=" Update "> </form> Any ideas? Quick note: the cgi script works correctly when the data is coming straight from this form. -
I need help with cURL. Submitting data like a html form.
Jarid replied to Jarid's topic in PHP Coding Help
On the code that i posted or the code that you posed? -
I need help with cURL. Submitting data like a html form.
Jarid replied to Jarid's topic in PHP Coding Help
<?php $action = $_GET['action'] ; $login = $_REQUEST['login'] ; $ID = $_REQUEST['ID'] ; $text = $_REQUEST['Unused10'] ; $submit = $_REQUEST['submit'] ; function filterBadWords($str){ // words to filter $badwords=array( "badword1", "badword2"); // replace filtered words with random spaces $replacements=array( "****", "***", "****" ); for($i=0;$i < sizeof($badwords);$i++){ srand((double)microtime()*1000000); $rand_key = (rand()%sizeof($replacements)); $str=eregi_replace($badwords[$i], $replacements[$rand_key], $str); } return $str; } $text = filterBadWords($text); print("Hello World"); print_r($action); print_r($login); print_r($ID); print_r($text); print_r($submit); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http:johnstonstudentcenter.com/members/cgi/pm.cgi'); curl_setopt($curl, CURLOPT_HEADER, true); // Make basic post request curl_setopt($curl, CURLOPT_POST, true); // Set your post data $post_data['action'] = '$action'; $post_data['login'] = '$login'; $post_data['ID'] = '$ID'; $post_data['Unused10'] = '$text'; $post_data['submit'] = '$submit'; curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_exec($ch); curl_close($ch); ?> Alright here are the errors: Warning: curl_exec(): supplied argument is not a valid cURL handle resource in /home/content/72/4744872/html/members/cgi/filter.php on line 50 Warning: curl_close(): supplied argument is not a valid cURL handle resource in /home/content/72/4744872/html/members/cgi/filter.php on line 51 Im guessing that i didn't group these together correctly. $post_data['action'] = 'modified'; $post_data['login'] = '$login'; $post_data['ID'] = '$ID'; $post_data['Unused10'] = '$text'; $post_data['submit'] = ' Update '; I also tried johnny's way with the same errors -
I need help with cURL. Submitting data like a html form.
Jarid replied to Jarid's topic in PHP Coding Help
Im going to try your way johnny it makes more sense then what i just came up with. Thanks for the reply -
I need help with cURL. Submitting data like a html form.
Jarid replied to Jarid's topic in PHP Coding Help
The pm.cgi script takes post. <?php $action = $_GET['action'] ; $login = $_REQUEST['login'] ; $ID = $_REQUEST['ID'] ; $text = $_REQUEST['Unused10'] ; $submit = $_REQUEST['submit'] ; function filterBadWords($str){ // words to filter $badwords=array( "badword1", "badword2"); // replace filtered words with random spaces $replacements=array( "***", "***"); for($i=0;$i < sizeof($badwords);$i++){ srand((double)microtime()*1000000); $rand_key = (rand()%sizeof($replacements)); $str=eregi_replace($badwords[$i], $replacements[$rand_key], $str); } return $str; } $text = filterBadWords($text); print("Hello World"); print_r($action); print_r($login); print_r($ID); print_r($text); print_r($submit); $curl_connection = curl_init('http://johnstonstudentcenter.com/members/cgi/pm.cgi'); curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); $post_data['action'] = 'modified'; $post_data['login'] = '$login'; $post_data['ID'] = '$ID'; $post_data['Unused10'] = '$text'; $post_data['submit'] = ' Update '; $result = curl_exec($curl_connection); curl_close($curl_connection); ?> -
I have looked up tutorials on Google. I am still confused. I built a php script that receives the data from my html form then filters out bad words. I am trying to get the script to resend the data to pm.cgi. The form was originally targeting pm.cgi but it needed filtered. This is why i am using php in the first place. Please help me pass these variables from the php script to the cgi script the same way that a html form would. Thank you. Here is my code, it prints correctly. I cannot get cURL to work. <?php $action = $_GET['action'] ; $login = $_REQUEST['login'] ; $ID = $_REQUEST['ID'] ; $text = $_REQUEST['Unused10'] ; $submit = $_REQUEST['submit'] ; function filterBadWords($str){ // words to filter $badwords=array( "badword1", "badword2"); // replace filtered words with random spaces $replacements=array( "****", "***", "****" ); for($i=0;$i < sizeof($badwords);$i++){ srand((double)microtime()*1000000); $rand_key = (rand()%sizeof($replacements)); $str=eregi_replace($badwords[$i], $replacements[$rand_key], $str); } return $str; } $text = filterBadWords($text); print_r($action); print_r($login); print_r($ID); print_r($text); print_r($submit); ?> I need to send the variables that i printed above to pm.cgi. Can you point me in the right direction? Thanks again!
-
I wrote this html form: <form action=filterwords.php method=post ENCTYPE="multipart/form-data" target="iFramestatus"> <input type=hidden name=action value=modified> <input type=hidden name=login value="%%login%%"> <input type=hidden name=ID value="%%ID%%"> <textarea cols=28 rows=4 name=Unused10>%%Unused10%%</textarea> <input type=submit name=submit value=" Update "> </form> Most of this form is filled out by my members area cgi script. I am trying to use filterwords.php to remove curse words from the textarea field "unused10" and then resubmit the data to my members area cgi script "pm.cgi" Here is my php script. <?php $action = $_REQUEST['action'] ; $login = $_REQUEST['login'] ; $ID = $_REQUEST['ID'] ; $text = $_REQUEST['Unused10'] ; $submit = $_REQUEST['submit'] ; function filterBadWords($str){ // words to filter $badwords=array( "[badword1]", "[badword2]"); // replace filtered words with random spaces $replacements=array( "[ ]", "[ ]", "[ ]" ); for($i=0;$i < sizeof($badwords);$i++){ srand((double)microtime()*1000000); $rand_key = (rand()%sizeof($replacements)); $str=eregi_replace($badwords[$i], $replacements[$rand_key], $str); } return $str; } $text = filterBadWords($text); ?> How do i send the modified data to pm.cgi? Did i use the filter script correctly? Thanks for the help
-
How can i use a variable to get an array from another php file?
Jarid replied to Jarid's topic in PHP Coding Help
The php script printed on the page it was included on. This does not happen if i replace $VALID_RATING_IDS = $RATETHESE; with $VALID_RATING_IDS = array("1", "2") Is there anyway i can include the array from PhpFileB.php into the script without it being printed on the page? -
I am trying to use the variable $RATETHESE to include an array into file A. The array is in file B. PhP File A include_once(dirname(__FILE__) . '/PhpFileB.php'); global $RATETHESE; $VALID_RATING_IDS = $RATETHESE; Php File B $RATETHESE = "array("1", "2");" For some reason it is printing the array on the page, and the array is not being used to run the script. Did i do anything wrong?
-
PhP File A include_once(dirname(__FILE__) . '/PhpFileB.php'); global $Ratethese; $VALID_RATING_IDS = $RATETHESE; Php File B $RATETHESE = "array("1", "2");" For some reason it is printing the array on the page, and the array is not being used to run the script. Did i do anything wrong?
-
Here is a section of php file A include_once(dirname(__FILE__) . '/PhpfileB.php') $VALID_RATING_IDS = $Ratethese Here is all of php file B $Ratethese = "array("1", "2",);" I need the var $VALID_RATING_IDS to = $Ratethese from file B I am trying to include an array from php file B in php file A. Is this possible? How can i accomplish this?
-
How can i set a default variable if one has not been set in the url?
Jarid replied to Jarid's topic in PHP Coding Help
Thanks for the help hiprakhar your solution worked, now i just have to adapt it for a few more pages. -
How can i set a default variable if one has not been set in the url?
Jarid replied to Jarid's topic in PHP Coding Help
I put <?php if (isset ($_GET['CiFrame'])) $Openme = $_GET['CiFrame']; else $Openme = '/NonMembersFeatured.php'; ?> In the body right above my iframe code <iframe name="CiFrame" width="727" height="805" src="<?php $Openme ?>" scrolling="auto" frameborder="0"></iframe> I uploaded the page to my server and opened it in my browser. The iframe did not open /NonMembersFeatured.php and when i right clicked and went to source code my iframe showed src="". Why is this not working? -
How can i set a default variable if one has not been set in the url?
Jarid replied to Jarid's topic in PHP Coding Help
I don't understand how to apply the code you provided. I set $Openme as the var. I still don't understand how to check the url for CiFrame or use a default value if CiFrame is not specified in the url. Here is what i tried next, however it did not work. Any ideas? <?php if (isset ($_GET['CiFrame'])) $Openme = 'CiFrame'; else $Openme = '/NonMembersFeatured.php'; ?> Iframe Code <iframe name="CiFrame" width="727" height="805" src="<?php $Openme ?>" scrolling="auto" frameborder="0"></iframe> Thank You -
I am using this php code <?php echo $_GET['CiFrame']; ?> to check the url for the variable CiFrame, this allows me to link to a page through my page containing the iframe. Here is my iframe code. <iframe name="CiFrame" width="727" height="805" src="<?php echo $_GET['CiFrame']; ?>" scrolling="auto" frameborder="0"></iframe> The problem is that if the url does not contain a variable the iframe will not open a page. How can i set a default variable if one is not provided? Thank You