next
Members-
Posts
140 -
Joined
-
Last visited
Everything posted by next
-
Actually that did make a difference, before it was giving me BAD REQUEST error. I slightly modified the code to go to the next page that only logged in users can see and it tells me: Your session has expired. Please log in again. <?php $url = 'http://fmpilot.com/Express/Desk/Login.asp'; $login_data = array( 'txtUserid' => 'my_user_id_info', 'txtPassword' => 'my_password_info', ); $fp = fopen("cookie.txt", "w"); fclose($fp); $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => $url, CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'], CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10, CURLOPT_POST => true, CURLOPT_COOKIEFILE => 'cookie.txt', CURLOPT_COOKIEJAR => 'cookie.txt', CURLOPT_FOLLOWLOCATION => true )); curl_setopt($ch, CURLOPT_POSTFIELDS, $login_data); curl_exec($ch); curl_setopt($ch, CURLOPT_URL, 'http://fmpilot.com/Express/Desk/Reports/ProviderReports.asp'); echo curl_exec($ch); curl_close($ch); ?>
-
Same thing. It just diplays the same login page and I don't see a cookie.txt created in the script directory. Does CURL just submits the form by the use of this option: CURLOPT_POST => true ? I don't need to click the submit button or anything of sort?
-
I'm trying to login to a website with curl, but can't figure out how it's supposed to be done. Here's my code so far: <?php $url = 'http://fmpilot.com/Express/Desk/Login.asp'; $login_data = array( 'txtUserid' => 'my_user_name', 'txtPassword' => 'my_password_', ); $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => $url, CURLOPT_USERAGENT => 'Mozilla/curl', CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $login_data, CURLOPT_COOKIEFILE => 'cookie.txt', CURLOPT_COOKIEJAR => 'cookie.txt', CURLOPT_FOLLOWLOCATION => true )); echo curl_exec($ch); curl_close($ch); //<input class="formfield" name="txtUserid" maxlength="50" value="" type="text"> //<input class="formfield" name="txtPassword" maxlength="50" type="password"> ?> How does CURLOPT_POSTFIELDS => $login_data, work? Did I do it correct here? "form field name" => "user input data" format? $login_data = array( 'txtUserid' => 'my_user_name', 'txtPassword' => 'my_password', );
-
Great, thanks!
-
Ok so i have a search form where onclick i need to erase default value ("Search!"): <form name="search_form" id="search_form" action="search.php" method="get"> <input type="text" id="search" name="search" value="Search!" size="30" maxlength="100" /> <input type="image" src="assets/search_btn.gif" id="search_btn" alt="search" /> </form> i want to erase stuff via function and not inline code, but it's not working out and firebug is not returning any errors. Here's my js code: function clear(default_value) { alert(this.value); if(this.value == default_value) this.value = ''; return void(0); } html: <input type="text" id="search" name="search" value="Search!" size="30" maxlength="100" onclick="clear('Search!');" /> the above is not working for some reason, however if i use inline code it works fine. Example: <input type="text" id="search" name="search" value="Search!" size="30" maxlength="100" onclick="if(this.value == 'Search!') this.value = '';" /> Here's a complete code incase it's needed: <?php require('Zend/Config.php'); require('Zend/Db/Adapter/Pdo/Mysql.php'); //load configuration file $config = new Zend_Config(require($_SERVER['DOCUMENT_ROOT'] . '/MovieTalk_2/config/config.php')); //connect to database try { $dbh = Zend_Db::factory($config->database); $dbh->setFetchMode(Zend_Db::FETCH_OBJ); } catch(Zend_Exception $e) { echo $e->getMessage(); } require($config->dir->business->forum); require($config->dir->business->user); $user = new User(); $loggedIn = true; $admin = false; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="http://yui.yahooapis.com/2.5.1/build/reset-fonts-grids/reset-fonts-grids.css" type="text/css" /> <link rel="stylesheet" href="styles/general.css" type="text/css" /> <title><?php echo $config->general->site_title; ?></title> <script language="javascript"> <!-- function clear(default_value) { alert(this.value); if(this.value == default_value) this.value = ''; return void(0); } window.onload = function() { if(document.images) { var imgNames = new Array("home_btn_h", "login_btn_h", "reg_btn_h", "del_forum_btn", "msgs_btn_h", "new_forum_btn_h", "reg_btn_h", "unread_btn_h"); var imgs = new Array(); for(var i=0; i<=imgNames.length; i++) { imgs[i] = new Image(87, 30); imgs[i].src="assets/" + imgNames[i] + ".gif"; } } } --> </script> </head> <body id="doc3" class="yui-t4"> <!--************************* ************************* ** Head contents: *logo *spider man image *navigation *search ************************* *************************--> <div id="hd"> <!--logo and spider man images--> <a href="<?php echo $config->dir->locations->index; ?>"><img src="assets/logo.gif" alt="MovieTalk" /></a> <div id="sp_man"></div> <!--Search input--> <form name="search_form" id="search_form" action="search.php" method="get"> <input type="text" id="search" name="search" value="Search!" size="30" maxlength="100" onclick="clear('Search!');"/> <input type="image" src="assets/search_btn.gif" id="search_btn" alt="search" /> </form> <!--*********************** ************************* ** Navigation ************************* *************************--> <ul id="navi"> <?php //If non-admin user is logged in if($loggedIn && !$admin) { ?> <li id="home"><a href="<?php echo $config->dir->locations->index; ?>" class="hidden"><span class="hidden">Home</span></a></li> <li id="messages"><a href="#" class="hidden"><span class="hidden">Messages</span></a></li> <li id="unread"><a href="#" class="hidden"><span class="hidden">Unread Posts</span></a></li> <li id="logout"><a href="#" class="hidden"><span class="hidden">Log out</span></a></li> <?php //if admin is logged in } else if($loggedIn && $admin) { ?> <li id="home"><a href="<?php echo $config->dir->locations->index; ?>" class="hidden"><span class="hidden">Home</span></a></li> <li id="messages"><a href="#" class="hidden"><span class="hidden">Messages</span></a></li> <li id="unread"><a href="#" class="hidden"><span class="hidden">Unread Posts</span></a></li> <li id="new"><a href="#" class="hidden"><span class="hidden">New Forum</span></a></li> <li id="delete"><a href="#" class="hidden"><span class="hidden">Delete Forum</span></a></li> <li id="logout"><a href="#" class="hidden"><span class="hidden">Log out</span></a></li> <?php //guest is viewing the forum. } else { ?> <form name="login_form" id="login_form" action="' . $_SERVER['PHP_SELF'] . '?login-attempt=true' . '" method="post"> <li><label for="username">Username:</label><input type="text" id="username" name="username" size="15" maxlength="50"/></li> <li><label for="password">Password:</label><input type="password" id="password" name="password" size="15" maxlength="50" /></li> <li> <input type="image" id="login" onmouseover="this.src='assets/login_btn_h.gif';" onmouseout="this.src='assets/login_btn.gif';" src="assets/login_btn.gif" alt="login" /> </li> </form> <li id="register"><a href="#"><span class="hidden">Register</span></a></li> <?php } ?> </ul> </div>
-
I'm trying to check and uncheck all checkboxes in myForm, but keep getting errors. JS: <script language="javascript"> function handleChboxes(type) { switch(type) { case 'select': for(var i = 0; i <= document.myForm.elements.length; i++) { if(document.myForm.elements[i].type == 'checkbox' && document.myForm.elements[i].checked = false) document.myForm.elements[i].checked = true; } break; case 'deselect': for(var i = 0; i <= document.myForm.elements.length; i++) { if(document.myForm.elements[i].type == 'checkbox' && document.myForm.elements[i].checked = true) document.myForm.elements[i].checked = false; } break; } } </script> form: echo '<form name="myForm" action="' . $_SERVER['PHP_SELF'] . '" method="post"><ul id="menu"> <li><a href="#" onClick="action(\'deselect\')">deselect all</a></li> <li><a href="#" onClick="action(\'select\')">select all</a></li> </ul></form>'; error #1: error #2: happens after i click "select all" same stuff happens when i click "deselect all". How would i go about fixing those? Thanks.
-
Ok, so i added path to ZF in php ini, but it's not working for some reason. Here's my error message that i get I checked and Loader.php and Front.php do exist in those directories. Why is this happening?
-
Yeah, i'm forcing myself to write portable code, so manually adding values is not really an option. Thanks for the help!
-
Oh, so doesn't actually write to file?
-
I'm trying to add path to Zend Framework through ini_set but it's not working. Code: $current_includes = ini_get('include_path'); $zend_path = $_SERVER['DOCUMENT_ROOT'] . '/Zend'; $incs = explode(';', $current_includes); if(!in_array($zend_path, $incs)) { if(ini_set('include_path', ';' . $incs . $zend_path)) echo 'path to Zend successfully added to configuration file, restart the server to apply changes.'; else echo 'unable to write to ini file'; } else echo 'Zend already exists'; When i run this code, i do get a success message, but ini remains the same. What am i doing wrong here?
-
Which is the most proper way to structure your application? Please share, thanks.
-
Thanks!
-
source snuppet:
-
How can i click a link based on where it redirects you? For instance i want to loop through all links on a page and make a click only if text "Add=1" is a part of href. for(var i=0; i<=document.links.length; i++) if(document.links.search['Add=1']) alert(document.links[i].href); i tried this, but it's not working. Thanks.
-
How can i make a progress bar or a simple text tracking of what is being uploaded? I currently have this code: <?php $server = '***'; $username = '***'; $password = '***'; $x = dir('S:\Accounting Scanning\LTD\2008\8724'); //if directory doesn't exist if($x == false) exit(); //get all file names and store them in "uploads" array while($f = $x->read()) { if(is_file($x->path . '\\' . $f) && $f != 'Thumbs.db') $uploads[] = $f; } $total_files = sizeof($uploads); //FTP try { //connect and login $fth = ftp_connect($server); ftp_login($fth, $username, $password); //change current directory ftp_chdir($fth, 'LTD'); //if files were found in the directory, lst them and close the connection $files = ftp_nlist($fth, '.'); if($files) { echo 'these files were found in LTD directory: <br />'; echo '<ul>'; foreach($files As $key => $file) echo '<li>'. $file .'</li>'; echo '</ul>'; ftp_close($fth); exit(); } //if no files were found in the directory, proceed with upload foreach($uploads As $key => $file) { if(!ftp_put($fth, $file, $x->path . "\\$file", FTP_BINARY)) $errors[] .= "<li>" . $x->path . "\\$file</li>"; else { $i++; $left = $total_files - $i; echo "currently uploading $file ---------------- $left files left to upload.<br />"; } } if($errors) { echo '<ul>'; foreach($errors as $key => $error) echo $error; echo '</ul>'; } ftp_close($fth); } catch(Exception $e) { echo $e->getMessage(); exit(); } ?> but this code displays my progress after all uploading is done, which is no good. Thanks in advance.
-
Wow, i think it's a bit early for me Thanks for pointing that out.
-
Where can i find a list of Dir's methods? There is nothing in PHP manual http://us.php.net/manual/en/class.dir.php . I see examples of "handle", "path", but i can't seem to find a list of what's available. Thanks.
-
i wish could delete this thread, i noticed that i missed ";" in my code. Please delete this thread. Thanks.
-
This is really ridiculous, i used PDO, but kept getting messages like this one: none of the fixes that i found online worked, so i figured hey, let me switch to mysqli since it's OO and supports stored procedures. To my surprise this one has a bug as well: i tried freeing results, tried to understand mysqli::multi_query but was unsuccessful. My question: is there a database class that will support all the new MySQL features and not bring me down with these retarded errors? I run PHP 5.2.5 on Windows. Thanks.
-
How does this feature works? I'm building a forum and about to get to this part, but have absolutely no idea on how to implement it. Could anyone explain please? Thanks.
-
I have a really strange problem, here's my code: <?php include('config/config.php'); include('lib/database.class.php'); //Database::connect(); try { $result = Database::query("CALL index_page_forum_info('general')", PDO::FETCH_ASSOC); echo print_r($result); foreach($result as $key => $row) echo '<br />' . $row['forum_title']; } catch(PDOException $e) { trigger_error($e->getMessage(), E_USER_ERROR); } ?> here's my output: I don't get it, how come my array contains all the necessary data, but outputs only first letter through "foreach" loop? Can anybody help? Thanks.
-
I can't figure out how to use this method can anyone help? For instance i have 2 procedures: 1) CALL get_forums('general'); (headers: forum_id, forum_title, forum_descr) 2) CALL count_threads(); (returns 1, retrieved with 'num_threads') i want to display it like this: ----- 1 ----- title ----- 1 ----- title ----- etc. i can't figure out how to retrieve info. Here is my code: <?php include('config/config.php'); //include('lib/database.class.php'); $dbh = new mysqli(SERVER, DB_USER, DB_PASSWORD, DB); $query = "CALL count_threads(); "; $query .= "CALL get_forums('general');"; $dbh->multi_query($query); do { $result = $dbh->store_result(); echo $result->fetch_object()->num_threads . '<br />'; $result->free(); $dbh->more_results(); while($result = $dbh->fetch_object()) echo $result->forum_title . '<br />'; } while($dbh->next_result()); ?> this query displays "1", then throws a fatal error: Fatal error: Call to undefined method mysqli::fetch_object() in E:\PortableApps\WOS\www\MovieTalk\test.php on line 17 PHP docs left me really confused :-\ Thanks in advance.