view raw
Patrick Parcheta Patrick Parcheta - 1 year ago 33
SQL Question

Simple form not working

I just have created custom form in Wordpress to add some comments fastly.
I have write simple form:

<form method='post' method=''>
<h3>Wpisz komentarze</h3>
<textarea name="komentarzex" rows="10" cols="30">
1 komentarz = 1 linia
<h3>Wpisz nazwy uzytkowników</h3>
<textarea name="uzytkownicxy" rows="10" cols="30">
1 uyztkownik = 1 linia
<h3> Dodatkowe ustawienia</h3>
Ile komentarzy musi mieć wpis aby dodało do niego dodatkowe komentarze: <input type="text" name="ilekomentarzy" value="0"><br>
Do ilu wpisów dodack komantarze? : <input type="text" name="ileposotownaeraz" value="200"><br>
Wpisz przedzial ile ma dodać komentarzy do wpisu : od <input type="text" name="odkoms" value="5"> do <input type="text" name="dokoms" value="20"><br>
<input type="submit" value="Dodaj komentarze" name="dodajmeykurwa" />

And its display in admin page very good:

But when I try to post comments its not working fine :(

Here is my code to do action:

if(isset($_POST['dodajmeykurwa'])) {
require_once('spintax.php' );
$komentarze = $_POST['komentarzex'];
$uzytkownicy = $_POST['uzytkownicxy'];

$rakoms = preg_split("/\r\n|\n|\r/", $komentarze);
$rausers = preg_split("/\r\n|\n|\r/", $uzytkownicy);

require_once ('wp-blog-header.php');
// ile koemntarzy musi miec post aby do niego dodac komentarz

$ilekomsmusimiec = $_POST['ilekomentarzy'];
$limitdodanychpostow = $_POST['ileposotownaeraz'];
global $wpdb;
// pobranie postów z liczbą komentarzy 0
$posty = $wpdb->get_results("SELECT id, comment_count FROM wp_posts WHERE post_type='post' AND post_status='publish' AND comment_count= $ilekomsmusimiec ORDER BY RAND() LIMIT $limitdodanychpostow");


if ($posty)
foreach ($posty as $p)
// losowe nicki i komentarze
$oidkoskoms = $_POST['odkoms'];
$dokadkoms = $_POST['dokoms'];
for ($i = $oidkoskoms, $size = $dokadkoms; $i < $size; $i++)
// ustawienia komentarza - wartości
$data = array(
'comment_post_ID' => $p->id,
'comment_author' => $spintax->process($rausers[$i]),
'comment_author_email' => '',
'comment_author_url' => 'http://',
'comment_content' => $spintax->process($rakoms[$i]),
'comment_type' => '',
'comment_parent' => 0,
'user_id' => rand(1, 100),
'comment_author_IP' => '',
'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)',
'comment_date' => current_time('mysql'),
'comment_approved' => 1,
} else
echo "Brak postow do ktorych mozna dodac komenatarze";

What I have do wrong?


You have duplicated method attribute on your form opening tag:


<form method='post' method=''>

Should be:

<form method='post' action=''>