Jump to content

adicrst

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Everything posted by adicrst

  1. works, thanks. Could you clarify for me why my function didn't worked ?
  2. i have this function that sanitizes the email, but for some reason it doesn't work for white spaces like 'test @test.com'. Why ? $string = 'test@test.com'; function spamcheck($mail) { $mail = filter_var($mail, FILTER_SANITIZE_EMAIL); if(filter_var($mail, FILTER_VALIDATE_EMAIL)) { return TRUE; } else { return FALSE; } } if (spamcheck($string) != FALSE) { $email = $sir; echo $email; } else { echo '<br />Invalid email address!'; $error = true; }
  3. well, i thought at something like this: to have a field in the user's table and keep the last time his HP have been decreased. This can happen only in some small and precise circumstencies like battle. So a code in the pages responsible for this to update that time. Another code in some pages like profile, battle, etc that extract that time and compares it with the server's current time and makes a difference. Let's say the HP decreasing was at 10:00 and now the time is 10:05. A code that does 10:05-10:00=5 => curent HP + 5 and updates the new value PS: i don't need the code, just ideas
  4. Something bugs me for some time and i want to know how could i create PHP script that does this: Every game (i'm talking about browser based games) have HP (health points). Let's say that the max HP is 10. From some reasons, the user's HP drops to 5, so he has only 5 more left. Now, my question is how could i make a script that every minute that passes, his HP to increase by 1 point. So if 2 minutes pass, his HP increases from 5 to 7, but it doesn't go beyond 10 (that is maxHP). I have the fallowing idea: using CronJob, make a script like this to execute itself every 1 minute: * extract all user's HP that is < then maxHP * add 1 to the previous value * update the database with the new HP value Doesn't this technique stress the database, considering that i make every minute hundred of queries if i have hundred of members in the game ? How could i find another solution ? Something based on the user, like everytime he refreshes his profile to know what was his last activity time and what is the current time and to make a difference and see how many minutes have passed and add to his HP the amount of points, but not to go over the maxHP. But how do i save his last activity time and the time he makes a refresh (refresh means he made another activity) and see how much points to add ?
  5. I want to create a form that will insert some news in a database, but to be restricted only to the owner that his username and pass are saved in the db, i made a small autentification. I have 2 files, autentificare.php and stiri.php -the fileautentificare.php has the purpouse to verify if the dates filled in the log in form are the same with the dates in the db -if the autentification is not made, the user is sent to the stiri.php page but a warning that sais he's not allowed is apearing. If the autentification is made corectly then he is sent to the stiri.php page again but a form for the news is showing on the page What it doesn't work is that the news are not inserted in the database.. i have 2 tables: DATE: id | user | pass| cod STIRI: id | titlu | continut | data here are the files autentificare.php <?php $con = mysql_connect("localhost","root",""); if (!$con) { die ("Conectare esuata!".mysql_error()); } mysql_select_db("pink_maindb",$con); $cod_generat = rand(0,9999); mysql_query("UPDATE date SET cod='$cod_generat' WHERE id='1' "); ?> <html> <body> <form action="stiri.php" method="post"> User: <input type="text" name="user"><br> Pass: <input type="password" name="pass"><br> Cod: <input type="text" name="cod" size="5" maxlength="4"> <?php echo "<b> $cod_generat </b><< Introduceti codul afisat !"; ?><br><br> <input type="submit" value="trimite"> </form> </body> </html> and stiri.php <?php $con = mysql_connect("localhost","root",""); if (!$con) { die ("Conectare esuata!".mysql_error()); } mysql_select_db("pink_maindb",$con); $select = mysql_query("SELECT user,pass,cod FROM date where ID=1"); while ($row=mysql_fetch_array($select)) { $usere = $row['user']; //usere este userul existent in db $passe = $row['pass']; //passe este parola existenta in db $code = $row['cod']; //code este codul existent in db } if (($usere == $_POST['user']) && ($passe == $_POST['pass']) && ($code == $_POST['cod'])) { echo "<Bine ai venit <b>".$_POST['user']."</b>"; echo "Completati urmatorul formular pentru a afisa o stire noua pe site<br><br> <form action='' method='post'> Titlu: <input type='text' name='titlu'><br> Continut: <textarea rows='15' cols='40' name='continut'></textarea><br> <input type='submit' value='trimite'> </form>"; $data = date("Y-m-d"); mysql_query("INSERT INTO stiri(titlu,continut,data) VALUES('$_POST[titlu]','$_POST[continut]','$data')"); } else echo "Datele furnizate nu sunt corecte !"; ?> <a href="autentificare.php">BACK</a> this part doesn't work because there isn't anything inserted in the db,beside the DATE if (($usere == $_POST['user']) && ($passe == $_POST['pass']) && ($code == $_POST['cod'])) { echo "<Bine ai venit <b>".$_POST['user']."</b>"; echo "Completati urmatorul formular pentru a afisa o stire noua pe site<br><br> <form action='trimis.php' method='post'> Titlu: <input type='text' name='titlu'><br> Continut: <textarea rows='15' cols='40' name='continut'></textarea><br> <input type='submit' value='trimite'> </form>"; $data = date("Y-m-d"); mysql_query("INSERT INTO stiri(titlu,continut,data) VALUES('$_POST[titlu]','$_POST[continut]','$data')"); } how can i corect it ?
  6. i did posted in the php forum but it was moved here by a mod thanks for the reply
  7. but i dont want a javascript. I want a pure PHP and i remember it was something like <a href="submit.php?SOMETHING HERE">link
  8. How can i use a submitting link instead of a button ? here is the simple form <form action="submit.php" method="post"> Name: <input type="text" name="name"> Age: <input type="text" name="age"> <input type="submit" name="send"> </form> nou instead of the button send i want a link to send the informations to the submit.php page
  9. Hi, my friend bough a pc and it didn't recived any drivers nor a technical book for the pc. It had linux installed and i formated it and installed windows. The problem is that i can't find the drivers for it so no sound. I downloaded a software and i found out what motherboard it has. I searched the internet and i still couldnt found something that works Can someone help me or has the drivers for : ID: 09/16/2005-SIS-755-6A7I3E1AC-00 Name: ECS 755-A2
  10. it works, thank you. Can u say what is wrong in my code and why is not working ?
  11. sorry for the double post, but i realized that at my own code the variables $row are not global and i dont know how to make it. @pocobueno1388: i get this error Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause
  12. i tried this <?php $con = mysql_connect("localhost","root",""); if (!$con) { die ('Eroare conectare'.mysql_error()); } //selectarea bazei de date mysql_select_db("rpg",$con); $query = "SELECT MAX(iduser) as max_user, SUM(bani) as max_bani, SUM(puncte) as max_puncte, (puncte + bani) as total FROM users"; $result = mysql_query($query)or die(mysql_error()); $row = mysql_fetch_assoc($result); print<<<HERE Total membri: {$row['max_user']}<br> Total bani: {$row['max_bani']}<br> Total puncte: {$row['max_puncte']}<br> Total bani and puncte: {$row['total']} HERE; ?> and i get Table 'rpg.users' doesn't exist also with my old code i tried <?php $con = mysql_connect("localhost","root",""); if (!$con) { die ('Eroare conectare'.mysql_error()); } //selectarea bazei de date mysql_select_db("rpg",$con); //extragerea datelor $result = mysql_query("SELECT * FROM user"); echo "<b>Membrii | Bani | Puncte</b><br>"; while($row = mysql_fetch_array($result)) { echo $row['username']." ".$row['bani']." ".$row['puncte']."<br>"; } //total membri $membri = mysql_query("SELECT MAX(iduser) FROM user"); while($row_m=mysql_fetch_array($membri)) { echo "<br><br>Total membri: ".$row_m[0]; } //total bani $bani = mysql_query("SELECT SUM(bani) FROM user"); while($row_b=mysql_fetch_array($bani)) { echo "<br>Total bani: ".$row_b[0]; } //total puncte $puncte = mysql_query("SELECT SUM(puncte) FROM user"); while($row_p=mysql_fetch_array($puncte)) { echo "<br>Total puncte: ".$row_p[0]; } //total puncte si bani $total=$row_b[0]+$row_p[0]; echo "<br><br>bani + puncte = ".$total; mysql_close($con); ?> and the output is Membrii | Bani | Puncte adicrst 100 150 adi 150 150 alin 100 150 Total membri: 3 Total bani:350 Total puncte: 450 bani + puncte = 0
  13. i have a database and i want to output the total of users,bani(money) and pucte(points) i made this script <?php $con = mysql_connect("localhost","root",""); if (!$con) { die ('Eroare conectare'.mysql_error()); } //selectarea bazei de date mysql_select_db("rpg",$con); //extragerea datelor $result = mysql_query("SELECT * FROM user"); echo "<b>Membrii | Bani | Puncte</b><br>"; while($row = mysql_fetch_array($result)) { echo $row['username']." ".$row['bani']." ".$row['puncte']."<br>"; } //total members $membri = mysql_query("SELECT MAX(iduser) FROM user"); while($row_m=mysql_fetch_array($membri)) { echo "<br><br>Total membri: ".$row_m[0]; } //total money $bani = mysql_query("SELECT SUM(bani) FROM user"); while($row_b=mysql_fetch_array($bani)) { echo "<br>Total bani: ".$row_b[0]; } //total points $puncte = mysql_query("SELECT SUM(puncte) FROM user"); while($row_p=mysql_fetch_array($puncte)) { echo "<br>Total puncte: ".$row_p[0]; } mysql_close($con); ?> the output is like this Membrii | Bani | Puncte adicrst 100 150 adi 150 150 alin 100 150 Total membri: 3 Total bani:350 Total puncte: 450 now i want to sum Total bani: 350 with Total puncte: 450 => 800. How do i do this ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.