Jump to content
php.lv forumi

ievada datut ar otro reizi


ziedinjsh

Recommended Posts

Sveiki!

 

Lieta tāda, nospiežot submit pogu izmet erroru un pasaka, ka kāds no lauciņiem ir tukš, nospiežot otro reizi vieņš ppievieno datus arī tad ja kāds no lauciņiem ir pa tiešām tukšs.

 


if($cat=="simple"){
$data = mysql_fetch_array(mysql_query("SELECT * FROM members WHERE email='".$_SESSION['email']."' LIMIT 1"));
echo "
<div id='result'></div>
<form method='post' action='process/addsimple_process.php' id='addsimple'>
<input type='hidden' name='author' value='".$data['username']."'><input type='hidden' name='mid' value='".$data['id']."'>
<p class='title'>Virsraksts</p>
<p><input type='text' name='title' class='input' style='width:590px;'></p>
<p class='title'>Ievads</p>
<p><textarea name='intro' class='introi'></textarea></p>
<p class='title'>Raksts</p>
<p><textarea name='article' class='articlei'></textarea></p>
<p><input type='submit' name='simple' value='Pievienot' class='button'></p>

</form>
";

}

 


$type = "simple";
$author = mysql_real_escape_string($_POST['author']);
$mid = mysql_real_escape_string($_POST['mid']);
$title = mysql_real_escape_string($_POST['title']);
$intro = mysql_real_escape_string($_POST['intro']);
$article = mysql_real_escape_string($_POST['article']);
$date = date("d.m.Y");

$statuss = "ok";

if($author=="" || $mid==""){
$error = "<h3 style='color:#ff0000;font-size:20px;'>Kļūda! Ielogojies vai reģistrējies.</h3>";
$statuss = "error";
}
if($title=="" || $intro=="" || $article==""){
$error = "<h3 style='color:#ff0000;font-size:20px;'>Kāds no lauciņiem ir palicis tukšs!</h3>";
$statuss = "error";
}

if($statuss<>"ok"){
echo $error;
}else{
mysql_query("INSERT INTO articles (type, author, mid, title, intro, article, date) VALUES ('$type', '$author', '$mid', '$title', '$intro', '$article', '$date')");
echo "<h3 style='color:green;font-style:20px;'>Paldies, raksts ir pievienots!</h3>";
echo "<meta http-equiv='refresh' content='2;url=index.php'>";
}

 


$(document).ready(function() {
       $('#addsimple').submit(function() {
               $.ajax({
                       type: "POST",
                       url: $('#addsimple').attr('action'),
                       data: $('#addsimple').serialize(),
                       success: function(data) {
                               $('#result').html(data);

                       }
               });
               return false;
       });
});

Edited by ziedinjsh
Link to comment
Share on other sites

vienreiz nospiežot parāda klūdu - kāds no lauciņiem ir palicis tukšs un nospiežot atkārtoti tad parāda lietotājvāru ar kuru esmu ielogojies un kurš būs tas author

 

ja tu to biji domājis šādi:


$type = "simple";
$author = mysql_real_escape_string($_POST['author']);
$mid = mysql_real_escape_string($_POST['mid']);
$title = mysql_real_escape_string($_POST['title']);
$intro = mysql_real_escape_string($_POST['intro']);
$article = mysql_real_escape_string($_POST['article']);
$date = date("d.m.Y");

$statuss = "ok";

if($author=="" || $mid==""){
$error = "<h3 style='color:#ff0000;font-size:20px;'>Kļūda! Ielogojies vai reģistrējies.</h3>";
$statuss = "error";
}
if($title=="" || $intro=="" || $article==""){
$error = "<h3 style='color:#ff0000;font-size:20px;'>Kāds no lauciņiem ir palicis tukšs!</h3>";
$statuss = "error";
}

if($statuss<>"ok"){
echo $error;
}else{
die($author);
mysql_query("INSERT INTO articles (type, author, mid, title, intro, article, date) VALUES ('$type', '$author', '$mid', '$title', '$intro', '$article', '$date')");
echo "<h3 style='color:green;font-style:20px;'>Paldies, raksts ir pievienots!</h3>";
echo "<meta http-equiv='refresh' content='2;url=index.php'>";
}

 

Edited by ziedinjsh
Link to comment
Share on other sites

  • 1 month later...


$first = mysql_real_escape_string($_POST['first']);
$last = mysql_real_escape_string($_POST['last']);
$nick = mysql_real_escape_string($_POST['nick']);
$email = mysql_real_escape_string($_POST['email']);
$password = mysql_real_escape_string($_POST['password']);
$password2 = mysql_real_escape_string($_POST['password2']);
$genere = mysql_real_escape_string($_POST['genre']);
$date = date("d.m.Y");
$statuss= "error";

if($first && $last && $nick && $email && $password && $password2 && $genere){
$statuss = "ok";
}else{
$error = $lang['013'];
$statuss = "error"; 
}

 

bet kad tiek aizpildīti visi lauciņi vienalga izmet erroru!

Link to comment
Share on other sites

Es jau nesaku, ka pēc.

 

Zienišjsšš... nu ja patiešām jūti, ka neiet tev tā lieta - es nezinu; mēģini ko citu. Vai tad profesijas trūkst? Gribi mājaslapu? Maksā tiem, kas mājaslapas veido.

 

Džīzas!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...