hi all,
i am having a projects page, in which we can create a project by giving projectname and allocate some memory(we had restriction on memory i;e 60MB). so i had created a project and allocated some memory of 65MB. so now i wil get a popup as "insufficient memory" on popup if i press ok that projectname and memory text box also getting empty so i need to get only memory text box empty.
Thank u.

Member Avatar for rajarajan2017

Where is your code?

Where is your code?

thanks for ur response. here is my code.

<html>
<body>
<script language="javascript" type="text/javascript">
		function check()
		{
			if(document.getElementById('txtname').value == "")
			{
				alert('Please enter projectname');
				return false;
				
			}
			
            if(document.getElementById('createdby').value == "")
            {
                alert('Please enter createdby');
                return false;
            }
		}
	</script>

<form action="projectcreation.php" method="post">
<table align="center">
	
	
	<tr>
		<td style="color: navy;">Projectname</td>
		<td><input id="txtname"  type="text" name="projectname"></td>
	</tr>
	
	<tr>
		<td style="color: navy;">Allocated memory</td>
		<td><input type="text" name="allocatedmemory"></td>
		<td><select name="size">
		<option value="MB">MB</option>
		<option value="KB" selected="selected">KB</option>
		</select>
		</td>
	</tr>
     <?php
if(isset($_POST['btn']))  
{
$id=$_GET['f1'];
@session_start();
require_once ("check.php");
createsessions($username,$password,$userid,$projectid,$projectname,$filename,$size,$allocatedmemory,$answer,$usedmemory,$Remainingmemory,$result);
$con=mysql_connect("10.70.1.248","invensis","invensis");
if(!$con)
    {
        die('Could not connect: ' . mysql_error());
    }         
mysql_select_db("database_myproject",$con);

if($_POST[size]== 'MB')
{
     $am=$_POST[allocatedmemory] ;
     $result=$am*1024;
      
}
else{
      $am=$_POST[allocatedmemory] ;
      $result = $am;
}
if($_POST[size]== 'KB')
{
    $am=$_POST[allocatedmemory];
    $test=round($am/1024,4);
    
}
else{
    $am=$_POST[allocatedmemory];
    $test=$am;
      
}
if( $result < $Remainingmemory)
{
$sql="INSERT INTO projects(projectname,allocatedmemory,createdby)
VALUES ('$_POST[projectname]','$test MB','$_SESSION[username]')";
echo "New Project Added";
if(!mysql_query($sql,$con))
 {
     die('Error:' . mysql_error());
 }
}                                          
else  
{                                     
echo "<script language='javascript'>
            alert('Insufficient Memory');
           </script>";
} 
}                    
?>
    
    
	<td></td>
	    <td><input type="submit" name="btn" value="Submit" onclick="return check();"></td>
</table>
</form>
</body>
</html>
Member Avatar for rajarajan2017

I think your page got refreshed, then you can use the method= "post" or "get" r8?. Retrieve the value by using:

$pname=_POST;

display the value in the project textbox

I think your page got refreshed, then you can use the method= "post" or "get" r8?. Retrieve the value by using:

$pname=_POST;

display the value in the project textbox

sorry i didnt understand as i am new to php. can u say it in brief.

Member Avatar for rajarajan2017
<?php
$pname=_POST['projectname'];
echo $pname;
?>

And I am not a programmer in php little bit I know. Trying to help thats it!

<?php
$pname=_POST['projectname'];
echo $pname;
?>

And I am not a programmer in php little bit I know. Trying to help thats it!

ya thank u i got it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.