Jump to content


Check out our Community Blogs

esial

Member Since 01 Sep 2012
Offline Last Active Sep 24 2012 09:20 PM
-----

Topics I've Started

php code to get days left

20 September 2012 - 08:47 AM

hi,
i need help in getting days and hours left. This is for a contract type thing, now say a customer subscribes for a 1 year contract, every time he logs in he gets to see the number of days and hours left for the contract to complete.

Say start_date_hours = x and end_date_hours= y.... where x and y is manually entered by me and stored in the database. When customer logs in, he can possibly click on a button called "calculate days_hours left" (or whatever is simpler) to see the number of days and hours left.

Please help.
Thank in advance,

confirm delete

19 September 2012 - 12:03 AM

hey,
i need a confirmation before deleting. i tried confirm (); i dont know, it does'nt work for some reason.
Everything works perfect, just that i need a confirmation before deleting-

in a file called thanks.php i have this

echo "<td><a href ='del.php?uid=$id'><font color='red'><center>Delete</center></font></a>";

i need a confirmation to display after he clicks on this


del.php looks like


<?php
$id =$_REQUEST['uid'];
mysql_query("DELETE FROM data WHERE uid = '$id'")
or die(mysql_error());
echo "<br />";
echo "The record was successfully deleted<br />";
?>

Please help,
Thanks in advance,

Refresh form after initial submission

17 September 2012 - 10:32 PM

Split from this topic.

i need help on this one please,
i have a form and after t submit it has to store all the values in the database. when i fill out the form and submit, everyhting works well but when i hit REFRESH it gets executed again,.what should i do? i guess i have to use sessions. here's my code

<!-- form here -->

<tr>
<td>&nbsp;</td>
<td><input type="submit" name="submit" id="submit" value="add" /></td>
</tr>
</table>
<?php
if (isset($_POST['submit']))
{
//include 'db.php';

	 $email_address=$_POST['email_address'] ;
	 $hardware_type= $_POST['hardware_type'] ;	
	 $brand=$_POST['brand'] ;
	 $model=$_POST['model'] ;
	 $serial_no=$_POST['serial_no'] ;
	 $date_of_purchase=$_POST['date_of_purchase'] ;
	 $warranty_date=$_POST['warranty_date'] ;
	 $software_brand=$_POST['software_brand'] ;
	 $software_type=$_POST['software_type'] ;
	 $software_version=$_POST['software_version'] ;
	 $licence_copy=$_POST['licence_copy'] ;
	 $licence_validity=$_POST['licence_validity'] ;
	 $licence_expiry_date=$_POST['licence_expiry_date'] ;

mysql_query("INSERT INTO `data`(email_address,hardware_type,brand,model,serial_no,date_of_purchase,warranty_date,software_brand,software_type,software_version,licence_copy,licence_validity,licence_expiry_date)
	 VALUES ('$email_address','$hardware_type','$brand','$model','$serial_no','$date_of_purchase','$warranty_date','$software_brand','$software_type','$software_version','$licence_copy','$licence_validity','$licence_expiry_date')");
	 }

?>
</form>
<table border="1">

<?php
//include("db.php");


$result=mysql_query("SELECT * FROM data");

while($test = mysql_fetch_array($result))
{
$id = $test['uid'];
echo "<tr align='center'>";
echo"<td><font color='black'>" .$test['uid']."</font></td>";
echo"<td><font color='black'>" .$test['email_address']."</font></td>";
echo"<td><font color='black'>". $test['brand']. "</font></td>";
echo"<td><font color='black'>". $test['model']. "</font></td>";
echo"<td><font color='black'>". $test['serial_no']. "</font></td>";
echo"<td><font color='black'>". $test['date_of_purchase']. "</font></td>";
echo"<td><font color='black'>". $test['warranty_date']. "</font></td>";
echo"<td><font color='black'>". $test['software_brand']. "</font></td>";
echo"<td><font color='black'>". $test['software_type']. "</font></td>";
echo"<td><font color='black'>". $test['software_version']. "</font></td>";
echo"<td><font color='black'>". $test['licence_copy']. "</font></td>";
echo"<td><font color='black'>". $test['licence_validity']. "</font></td>";
echo"<td><font color='black'>". $test['licence_expiry_date']. "</font></td>";


echo"<td> <a href ='view.php?uid=$id'>Edit</a>";
echo"<td> <a href ='del.php?uid=$id'><center>Delete</center></a>";
		
echo "</tr>";
}
mysql_close($conn);

?>
</table>
</body>
</html>

MYSQL help

15 September 2012 - 08:47 AM

hi,
I wanted to copy email addresses from one table to another. i used this command below and it worked
"INSERT INTO data (email_address) SELECT email_address FROM cw_users";

What i need is, every time when new users register i want their email address to be added to the DATA table. With this above command every time i refresh all the email addresses gets inserted into the database AGAIN.

What should i do to get this fixed?
thanks,

login script help!

01 September 2012 - 07:42 PM

i downloaded this login script from code.google.com/p/php-login-script/

please check the uploaded images.Attached File  1.jpg   16.13KB   63 downloadsAttached File  2.jpg   16.3KB   58 downloads

in the 1st pic as you can see in the url, it is localhost/loginscript/index.php. Everything is fine with this page. when i login it goes to the page shown in pic 2. In the url it is websites/loginscript/main.php.
When i remove "websites" from the url everything works fine. How do i get rid of this "websites" folder.
I tried to change this php_self in the form action to main.php. it does'nt seem to work please help.


Any good login script suggestions?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download