Jump to content
php.lv forumi

Teksta ievietošana un lasīšana no MySQL


SkyD

Recommended Posts

Labdien. Tātad sākšu ar to, ka gribētu, lai jūs man pasakat, kas man te nav pareizs.

Forma:

<form name="FormName" action="pievienot.php" method="post">
<input name="logins" type="text" value="">
<input name="parole" type="text" value="">
<input type="submit" value="Send">

 

Logina un paroles pievienošana (pievienot.php):

<?
$hostname="localhost";
$mysql_login="root";
$mysql_password="";

$db = mysql_connect("$hostname", "$mysql_login" , "$mysql_password") or die("Neder!");

if (!(mysql_select_db("tests",$db)))
{
 echo "nav kaartiibaa ar DB<br>";
}

if($q){ echo "<br>";}

$q == mysql_query("INSERT INTO admini (logins,parole) VALUES ('$logins','$parole')")or die(mysql_error());

if($q) { echo "Pievienots!"; }

?>

<?
error_reporting(E_ALL);
?>

 

Un nolasīšana (lasisana.php):

 

<?php

$connection = mysql_connect ("localhost","root", "") or die ("Nevar savienot!");

$db = mysql_select_db ("tests",$connection) or die ("Nevar savienot ar datu bāzi!");

$sql_query = "SELECT * FROM admini";

$result = mysql_query($sql_query);
if(mysql_num_rows($result))
{
while($row = mysql_fetch_row($result))
{
echo (": $row[4]");
}
}
else
{
echo "bāzē nekā nav..";
}

?>

<?
error_reporting(E_ALL);
?>

 

Nu lieta tāda, ka pie nolasīšanas rāda vairākus punktinjus.. (::::) <-- taadus.. Un kad pievieno veel klāt kautko, + veel punktinji.

Edited by SkyD
Link to comment
Share on other sites

  • Replies 48
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Un register_global jabuut off??

 

22 rinda:

$q == mysql_query("INSERT INTO admini (logins,parole) VALUES ('$_POST['logins']','$_POST['parole']')")or die(mysql_error());

 

un error:

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in d:\lapa\a.php on line 22

Edited by SkyD
Link to comment
Share on other sites

Hmm... Vajag taa, ierakstot loginu un paroli, lai paarbauda vai ir pareizs vai nepareizs.. Logins un parole atrodas datu baazee.. MYSQL!

<?
$hostname="localhost";
$mysql_login="root";
$mysql_password="";

$db = mysql_connect("$hostname", "$mysql_login" , "$mysql_password");

if (!(mysql_select_db("admin",$db)))
{
echo "nav kaartiibaa ar DB<br>";
}
else {
$q = mysql_query("SELECT COUNT(*) FROM admini WHERE logins='$logins' AND parole=MD5('$parole')");
list($skaits) = mysql_fetch_row($q);
if ($skaits==0) {
echo 'tu esi launais haxorz';
} else {
echo 'welcome to mai page!';
}
}
?>

 

Kas nav kaartiibaa?? Toch zinu kaads ir lietotājvārds un parole ir MD5 kodeeta... Kad rakstu iekshaa, un nospiezhu OK pasaka tu esi launais haxorz... Bet vajadzeetu welcome to mai.... Un tabulaa admini ir viens ieraksts, proti tas logins un parole, kura ir pasleepta zem MD5...

Edited by SkyD
Link to comment
Share on other sites


×
×
  • Create New...