Jump to content
php.lv forumi

Neupdeito tekstu.


zintis8789

Recommended Posts

Man ir sads kods:

<script type="text/javascript" src="ckeditor.js"></script>





<?php

include("config.php");
$u = $_GET['id'];
$result12 = mysql_query("SELECT * FROM `jaunumi` WHERE id='$u'");
$row1 = mysql_fetch_assoc($result12)or die(mysql_error());
$nosaukums = $row1[nos];
$ie = $row1[ievads];
$tests = $row1[zina];



$nos = $_POST['nos'];
$zina = $_POST['zina'];


$ievads = $_POST['ievads'];


mysql_query("SET NAMES UTF8 COLLATE utf8_general_ci"); 



if(isset($_POST['submit'])){

if(!$nos || !$zina || !$ievads){
echo "<font color=red>Aizpildi visus laukumus</font>";
echo "<meta http-equiv='refresh' content='0; url=index.php'>";
}else{
$u = $_GET['id'];
mysql_query("UPDATE jaunumi SET nos='$nos', zina='$zina', ievads='$ievads' WHERE id='$u' ");






echo "<font color=green>Esi veiksmigi editojis jaunumus</font> ";


}
}
?>


	<center>






			<form method="post" action="" >

Nosaukums: <input type=text name=nos value="<? echo $nosaukums; ?>" >


<p>Ievads:
<textarea name=ievads >
<? echo $ie; ?>
</textarea>
<p>Teksts:
<textarea name=zina >
<? echo $tests; ?>
</textarea>

<p> <input type=submit name=submit value=EDITOT>


</p>

</form>


		<script type="text/javascript">
			CKEDITOR.replace( 'zina' );
			CKEDITOR.replace( 'ievads' );
		</script>

Es izvelu tekstu no db editoju spiezu lai saglaba bet nesaglabajas izmainas.

Link to comment
Share on other sites

<script type="text/javascript" src="ckeditor.js"></script>

<?php

include("config.php");
$u = $_GET['id'];
$result12 = mysql_query("SELECT * FROM `jaunumi` WHERE id='$u'");
$row1 = mysql_fetch_assoc($result12)or die(mysql_error());
$nosaukums = $row1[nos];
$ie = $row1[ievads];
$tests = $row1[zina];

$nos = $_POST['nos'];
$zina = $_POST['zina'];

$ievads = $_POST['ievads'];

mysql_query("SET NAMES UTF8 COLLATE utf8_general_ci"); 

if(isset($_POST['submit'])){
	if(!$nos || !$zina || !$ievads){
		echo "<font color=red>Aizpildi visus laukumus</font>";
		echo "<meta http-equiv='refresh' content='0; url=index.php'>";
	}else{
		$u = $_GET['id'];
		mysql_query("UPDATE jaunumi SET nos='$nos', zina='$zina', ievads='$ievads' WHERE id='$u' ");
		echo "<font color=green>Esi veiksmigi editojis jaunumus</font> ";
	}
}
?>

<center>

<form method="post" action="">
Nosaukums: <input type=text name=nos value="<? echo $nosaukums; ?>" >
<p>
	Ievads:
	<textarea name=ievads >
	<? echo $ie; ?>
	</textarea>
<p>Teksts:
	<textarea name=zina >
	<? echo $tests; ?>
	</textarea>
<p>
	<input type=submit name=submit value=EDITOT>
</p>
</form>

<script type="text/javascript">
CKEDITOR.replace( 'zina' );
CKEDITOR.replace( 'ievads' );
</script>

 

Bet te tik un tā ir 101 kļūda. Kaut kādi tagi sākās, bet nekur nebeidzās... Nav norādīts formai action atribūta vērtība...

Link to comment
Share on other sites

$u = $_GET['id'];

mysql_query("UPDATE jaunumi SET nos='$nos', zina='$zina', ievads='$ievads' WHERE id='$u' ");

 

uzraksti kodam augšā:

 

echo "<pre>";

print_r($_POST);

echo "</pre>";

 

un apskaties, kādas vērtības tiek padotas no formas...

Link to comment
Share on other sites

$u = $_GET['id'];

mysql_query("UPDATE jaunumi SET nos='$nos', zina='$zina', ievads='$ievads' WHERE id='$u' ");

eude runāja par id, ka tam ir jābūt vai nu html formā vai adresē

 

debugojot skaties gan get, gan post vērtības

echo '<pre>' . print_r($_GET, 1) . print_r($_POST, 1) . '</pre>';

Edited by 2easy
Link to comment
Share on other sites

atvainojos, ka biju neskaidri uzrakstījis.

id trūkst formā, jo tur nav neviena lauka ar id vērtību ko padod, lai var ierakstīt datubāzē.

un tā kā tev nav uzrakstīts formai action galamērķis, tad to nevar arī iegūt no adreses jeb no šī $u = $_GET['id'];

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...