How to add a new category to this script ?

Discussion in 'PHP' started by Whippet75, Mar 26, 2009.

  1. #1
    <h1>Step 2: Submit to directories</h1>
    
    <input id="marticle" type="hidden" value="<?=$userarticle?>" />
    
    <?php
    if (isset($skip)){
     $_SESSION["skipped"][$dirid]=1;
    }
    
    if (isset($sendit)){
     $eredm = mysql_query("SELECT * FROM articles WHERE aid=$userarticle") or die(mysql_error());
     extract(mysql_fetch_array($eredm));
     $eredm = mysql_query("SELECT * FROM article_dirs WHERE adid=$dirid") or die(mysql_error());
     extract(mysql_fetch_array($eredm));
     $article = nl2br($article);
     include("./article/Curl.class.php");
     $curl =& new Curl();
     
     if (($atype==0) && ($cat)){
      // logging in
      $page = $curl->post("$aurl/signin.php", array('used'   => $aemail,	'part' => $apassword,'sbmSubmit' => 'Sign In'));
    
      // posting
        $page = $curl->get("$aurl/member/newarticle.php");
      	$dom = new DOMDocument();
        @$dom->loadHTML($page);
    	
    	$xpath = new DOMXPath($dom);
        $inputs = $xpath->evaluate("/html/body//input");
    	
    
    	for ($i = 0; $i < $inputs->length; $i++) {
    	 $input = $inputs->item($i);
    	 $tid = $input->getAttribute('id');
    	 if ($tid=='userInput') $thisid = $input->getAttribute('value');
    	}
    	
    
    
      $page = $curl->post("$aurl/goarticle.php", array(
    		'mode'=>'add',
    		'cmbCategory'   => $cat,	
    		'txtTitle' => $atitle,
    		'txtKeyword' => $akeywords,
    		'txtAbstract' => $aabstract,
    		'txtAuthorResource' => $aresource,
    		'txtArticle' => $article,
    		'userInput' => $thisid,
    		'smbSubmit' => 'Submit'));
    		
    		
       $page = $curl->get("$aurl/member/newarticle.php");
       if (substr_count($page,"Can not add new Article")>0){
        
        print("<center>Something went wrong<br /></center>");
    
    	
       } else {
        // adding submit to database
        $eredm = mysql_query("INSERT INTO article_submits(aaid,adid) VALUES($userarticle,$dirid)") or die(mysql_error());
       }
     }
     if (($atype==1) && ($cat)){
      	$page = $curl->post("$aurl/?a=submit", array(
    		'articlecategory'   => $cat,	
    		'articletitle' => "$atitle",
    		'articlekeywords' => "$akeywords",
    		'articlesummary' => "$aabstract",
    		'articleabout' => "$aresource",
    		'articletext' => "$article",
    		'submit' => 'Submit')) or die("error");
    		
    	if (!substr_count($page,"successfully")>0) {
    	    print("<center>Something went wrong<br /></center>");
    	} else {
        // adding submit to database
        $eredm = mysql_query("INSERT INTO article_submits(aaid,adid) VALUES($userarticle,$dirid)") or die(mysql_error());
        }
     }
     
     if (($atype==2) && ($cat)){
       $page = $curl->post("$aurl/index.php?page=userarticles",array(
        'article_title' => $atitle,
    	'article_author' => "$afirstname $alastname",
    	'article_category_id' => $cat,
    	'article_snippet' => $aabstract,
    	'article_summary' => $article,
    	'submitarticle' => "Submit Article",
    	'article' => 1
       ));
    
    
        // adding submit to database
        $eredm = mysql_query("INSERT INTO article_submits(aaid,adid) VALUES($userarticle,$dirid)") or die(mysql_error());
      
       
     }
     
    }
    ?>
    
    <div id="mainarea" style="width: 100%; text-align: center;" >
    
    </div>
    
    <script>
     ajaxRequest('getnew_article.php', 'site=<?php echo $userarticle; ?>');
    </script>
    Code (markup):
    I want to add $atype==3 to this code which enables login and post to the same script used on this site:

    http://www.article-4-content.info/
    Code (markup):
    I thought that this would work:

     // logging in
      
    if (($atype==3) && ($cat)){
    
       $page = $curl->post("$aurl/index.php?page=login", array('used'   => $aemail,	'part' => $apassword,'sbmSubmit' => 'Sign In'));
    
       $page = $curl->post("$aurl/index.php?page=submitarticle",array(
        'article_title' => $atitle,
    	'article_author' => "$afirstname $alastname",
    	'article_category_id' => $cat,
    	'article_snippet' => $aabstract,
    	'article_summary' => $article,
    	'submitarticle' => "Submit Article",
    	'article' => 1
       ));
    Code (markup):
    However, this does not work....any thoughts ?
     
    Whippet75, Mar 26, 2009 IP
  2. aaron d.

    aaron d. Peon

    Messages:
    37
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The script only uses a variable category. How do select/set the category?
     
    aaron d., Mar 26, 2009 IP
  3. Whippet75

    Whippet75 Well-Known Member

    Messages:
    1,599
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    155
    #3
    The category is selected in the database:

    [​IMG]

    It is (($atype==3) that is causing the script to hang...
     
    Whippet75, Mar 26, 2009 IP