LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-22-2005, 03:15 AM   #1
verbatim
Member
 
Registered: Apr 2005
Posts: 31

Rep: Reputation: 15
form action ="?" ... where is my form posting to?


I am trying to submit a form automatically with a cURL script i have configured, but i dont know what my CURLOPT_URL should be?


I dont know where the action page is because the only thing there is a '?'.


PHP Code:
<"form action="?" method="POST"> 
Is anyone familiar with this type of thing?

In the attempt to find where the variables are posted to, i have looked in other pages downloaded with the software for a list of the variables. No Luck, i only found one page that makes them into an array:


PHP Code:
    $res = array();
    
$res['database'] =
             array(
'title'       => INSTALL_CAT_DB,
                   
'description' => INSTALL_CAT_DB_DESC,
                   
'items' => array(array('var'         => 'dbType',
                                          
'title'       => INSTALL_DBTYPE,
                                          
'description' => INSTALL_DBTYPE_DESC,
                                          
'type'        => 'list',
                                          
'default'     => 'mysql',
                                          
'flags'       => array('nosave''simpleInstall''probeDefault')),

                                    array(
'var'         => 'dbHost',
                                          
'title'       => INSTALL_DBHOST,
                                          
'description' => INSTALL_DBHOST_DESC,
                                          
'type'        => 'string',
                                          
'default'     => 'localhost',
                                          
'flags'       => array('nosave''simpleInstall')),

                                    array(
'var'         => 'dbUser',
                                          
'title'       => INSTALL_DBUSER,
                                          
'description' => INSTALL_DBUSER_DESC,
                                          
'type'        => 'string',
                                          
'default'     => 'mem',
                                          
'flags'       => array('nosave''simpleInstall')),

                                    array(
'var'         => 'dbPass',
                                          
'title'       => INSTALL_DBPASS,
                                          
'description' => INSTALL_DBPASS_DESC,
                                          
'type'        => 'protected',
                                          
'default'     => '',
                                          
'flags'       => array('nosave''hideValue''simpleInstall')), 
any idea where they variables [dbType, dbName etc] are posted to so i can set the CURLOPT_URL ?

Last edited by verbatim; 05-22-2005 at 03:16 AM.
 
Old 05-22-2005, 04:41 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
if no page is specified, the same page is the target. the "?" there is as in "something.html?var1=abc&var2=xyz" and won't have any effect as there are no params. the whole tag could just not be there.
 
Old 05-23-2005, 06:55 PM   #3
verbatim
Member
 
Registered: Apr 2005
Posts: 31

Original Poster
Rep: Reputation: 15
thanks, knowing that the "?" means the php script action is back to the same script/page.

I would think this would solve my puzzle, it does not.

The puzzle: try to submit info to a form using cURL.

The puzzle variables:

1. the url of the form: www.mysite.com/userz/mel/sy_admin.php?sy[step]=2b

2. actual code of the page:

[php]
<?php
require_once 'sy/sy_admin.php';
?>

note: sy/sy_admin.php is in my home directory. /home/sy/sy_admin.php

3. critical code of sy/sy_admin.php : [i think, may not be important]
PHP Code:
<?php
include('sy_config.inc.php');

if (
IS_installed === false) {
    require_once(
S9Y_INCLUDE_PATH 'include/functions_installer.inc.php');
    require_once 
S9Y_INCLUDE_PATH 'include/functions_config.inc.php';
    
$css_file 'sy.css.php?sy[css_mode]=sy_admin.css';
} else {
    
$css_file sy_rewriteURL('sy_admin.css');
}
<
html>
    <
head>
        <
title><?php echo sy_ADMIN_SUITE?></title>
        <meta http-equiv="Content-Type" content="text/html; charset=<?php echo LANG_CHARSET?>" />
        <link rel="stylesheet" type="text/css" href="<?php echo $css_file?>" />
        <script type="text/javascript">
        function spawn() {
            if (self.Spawnextended) {
                Spawnextended();
            }

            if (self.Spawnbody) {
                Spawnbody();
            }

            if (self.Spawnnugget) {
                Spawnnugget();
            }
        }
        
        function SetCookie(name, value) {
            var today  = new Date();
            var expire = new Date();
            expire.setTime(today.getTime() + (60*60*24*30));
            document.cookie = 'sy[' + name + ']='+escape(value) + ';expires=' + expire.toGMTString();
        }
        </script>
    </head>
    <body id="sy_admin_page" onload="spawn()">   

<?php
if (!isset($sy['syPath']) || IS_installed === false || IS_up2date === false ) {
    if (
IS_installed === false) {
        
$file 'include/admin/installer.inc.php';
    } elseif ( 
IS_up2date === false ) {
        
$file 'include/admin/upgrader.inc.php';
    } else {
        
$file ''// For register_global, safety
    
}
?>
?>
Now one of the functions in installer.inc.php is to print the form template.

This may all be irrelevant in what i am trying to do, if so please let me know.

My current curl attempt is:

PHP Code:
<?php

 $my_data 
= array( 
'dbType' => 'mysql',
  
'dbHost' => 'localhost',
  
'dbUser' => 'mem',
  
'dbPass' => 'letmein',
  
'dbName' => 'mem_com_-_sy',
  
'dbPrefix' => 'mel_',
  
'dbPersistent' => 'false',
  
'syPath' => '/var/www/html/userz/mel/',
  
'uploadPath' => 'uploads/',
  
'syHTTPPath' => '/userz/mel/',
  
'templatePath' => 'templates/',
  
'uploadHTTPPath' => 'uploads/',
  
'baseURL' => 'http://www.mysite.com/userz/mel/',
  
'autodetect_baseURL' => 'false',  //dont know if true should have quotes around it it doesnt in config file
  
'indexFile' => 'index.php',
  
'user' => 'mel',
  
'pass' => 'thanks',
  
'realname' => 'mel',  //should get from signup p h p
  
'email' => 'michael@hotmail.com',  //should get from signup p h p
  
'want_mail' => 'true',  //dont know if true should have quotes around it it doesnt in config file
  
'allowSubscriptions' => 'true',  //dont know if true should have quotes around it it doesnt in config file
  
'blogTitle' => 'John Does personal blog',
  
'blogDescription' => 'My little place on the web...',
  
'lang' => '',  //dont know if true should have quotes around it it doesnt in config file
  
'lang_content_negotiation' => 'false',  //dont know if true should have quotes around it it doesnt in config file
  
'fetchLimit' => '15',  //dont know if true should have quotes around it it doesnt in config file
  
'useGzip' => 'true',  //dont know if true should have quotes around it it doesnt in config file
  
'wysiwyg' => 'false',  //dont know if true should have quotes around it it doesnt in config file
  
'XHTML11' => 'false',  //dont know if true should have quotes around it it doesnt in config file
  
'enablePopup' => 'false',  //dont know if true should have quotes around it it doesnt in config file
  
'embed' => 'false',
  
'top_as_links' => 'false',   //dont know if true should have quotes around it it doesnt in config file
  
'blockReferer' => ',',
  
'rewrite' => 'array()',  //dont know if true should have quotes around it it doesnt in config file
  
'serverOffsetHours' => '0',  //dont know if true should have quotes around it it doesnt in config file
  
'showFutureEntries' => 'false',  //dont know if true should have quotes around it it doesnt in config file
  
'magick' => 'false',  //dont know if true should have quotes around it it doesnt in config file
  
'convert' => '/usr/local/bin/convert',
  
'thumbSuffix' => 'syThumb',
  
'thumbSize' => '110',  //dont know if true should have quotes around it it doesnt in config file
                
);
               
//    This section constructs the field/value pairs of the form
//    field1=value1&field2=value2&field3=value3
$data_string '';
$add_ampersand FALSE;
foreach (
$my_data as $key => $value)
{
    if (
$add_ampersand)
    {
              
        
$data_string .= '&';
    }
    
$data_string .= $key '=' $value;
    
$add_ampersand TRUE;
}

//    Get a CURL handle
$curl_handle curl_init ();

curl_setopt($curl_handleCURLOPT_URL'http://www.mysite.com/userz/mel/sy_admin.php?sy[step]=2b');

curl_setopt($curl_handleCURLOPT_USERAGENT'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)');
curl_setopt ($curl_handleCURLOPT_RETURNTRANSFER1);
curl_setopt($curl_handleCURLOPT_HEADER1);
$result=curl_exec ($curl_handle);
curl_close ($curl_handle);

preg_match_all("/Set\-Cookie\:.*?\;/"$result$matches);
$cookiejar "";
foreach (
$matches[0] as $cookie) {
$cookiejar .= str_replace("Set-Cookie: """$cookie).' ';
}

preg_match("/Location\:.*?\n/"$result$matches);
$nexturl str_replace("\r"""str_replace("\n"""str_replace("Location: """$matches[0])));

// the 3 lines below were jst 4 test purposes to make sure the variables were getting set
print $cookie;    // ex result: Set-Cookie: PHPSESSID=dcd730a95f8b428f7dbd9fc1e6687d1a
print $nexturl;   // < got no result
print $cookiejar// ex result PHPSESSID=dcd730a95f8b428f7dbd9fc1e6687d1a


//    Get a CURL handle
$curl_handle curl_init ();
curl_setopt($curl_handleCURLOPT_URL$nexturl);
curl_setopt($curl_handleCURLOPT_USERAGENT'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)');
curl_setopt($curl_handleCURLOPT_REFERER'http://www.mysite.com/userz/mel/sy_admin.php?sy[step]=2b?');  
curl_setopt($curl_handleCURLOPT_COOKIE$cookiejar);
curl_setopt ($curl_handleCURLOPT_POST1);
curl_setopt ($curl_handleCURLOPT_POSTFIELDS$data_string);
curl_setopt($curl_handleCURLOPT_RETURNTRANSFER1);
curl_setopt($curl_handleCURLOPT_HEADER1);
curl_setopt($curl_handleCURLOPT_TIMEOUT300);
$result=curl_exec ($curl_handle);
curl_close ($curl_handle);

//    Process the return
print $result;
?>
I notice that the initial form page is: http://www.mysite.com/userz/mel/sy_admin.php?sy[step]=2b
and after filling out the form the normal way
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I "submit" an HTML <Form> with Javascript? nickiv Programming 3 06-13-2005 06:41 AM
pointers of the form "**a" in C dreamgoat Programming 6 04-27-2005 04:54 AM
form "post" not passing var niehls Programming 10 10-14-2003 05:19 PM
How to add Plugin in the form of "C" file ? suriyamohan Linux - Software 0 08-30-2003 01:52 AM
problms w/ php 4.2.1 mozilla 0.9.9 enctype="mutlipart/form-data" w/ phpWebSite 0.8.3 coea77 Linux - Software 1 10-10-2002 03:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration