function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sakthi169Sakthi169 

How to prevent resubmit the form value on refresh the page

Hi,

I need to prevent the form value re-submit on refresh(reload the page). I create page with validation , now i facing the problem once submit the i display the success message.When i refresh or reload the page it re-submit the page again(i put the validation duplicate check for mobile) and it shows the Error Message. How to reload the page without re-submit the form value. My code is 
<?php
// session_start() has to go right at the top, before any output!
session_start();
?>
<?php
  
	$username="xxxxxx";
	$pwd="xxxxxx";
	$st="xxxxxxxxx";
    $i=0;
	try{
		
            require_once ('soapclient/SforcePartnerClient.php');
            require_once ('soapclient/SforceEnterpriseClient.php');

		$mySforceConnection =new SforceEnterpriseClient();
		$mySforceConnection->createConnection("soapclient/enterprise.wsdl.xml");
		$mySforceConnection->setEndpoint('https://test.salesforce.com/services/Soap/c/36.0/0DFO000000001Oi');
		$mySforceConnection->login($username, $pwd.$st);
		//Checking no exception is thrown
		$i=1;
	}	
	catch(Exception $e){
		echo $e;
	}
    
    // On Click of the insert button
	if(@$_REQUEST['OK']) {

    //First check for validation
	if($_REQUEST['name'] == null || $_REQUEST['name'] == '') {
		echo "First Name can't be blank";	
	} else if($_REQUEST['lastName'] == null || $_REQUEST['lastName'] == '') {
		echo "Last Name can't be blank";	
	} else if($_REQUEST['mobNo'] == null || $_REQUEST['mobNo'] == '') {
		echo "Mobile Number can't be blank";	
	} else if($_REQUEST['email'] == null || $_REQUEST['email'] == '') {
		echo "Email can't be blank";	
	}else {
		// Checking no exception is iccured during login
		if($i==1) {
			 try {
			 	// Checking whether Phone number exists in salesforce or not?
				$query = "SELECT Id,LastName from Account where PersonMobilePhone='".$_REQUEST['mobNo']."'";
				$response = $mySforceConnection->query($query);
				$count=0;
				foreach ($response->records as $record) {
					$count++;
					break;
				}
				// if count is greater than 0, this means phone alredy exists
				if($count > 0) {
					echo "Mobile Number already exists";
				} else {
					$records = array();

                $records[0] = new stdclass();
                $records[0]->FirstName = $_REQUEST['name'];
                $records[0]->LastName = $_REQUEST['lastName'];
                $records[0]->PersonMobilePhone = $_REQUEST['mobNo'];
				$records[0]->CustomLandLine__c = '';
				$records[0]->City__c = 'Mumbai';
				$records[0]->Source__c = 'Database';
					$records[0]->OwnerId = '00590000002QqfJ';
					 $response = $mySforceConnection->create($records, 'Account');
					 echo '<div style=" background:#00FF00;height:25px;><font size="4"><center><b>'."Lead Inserted Successfully".'</b>  
												 </center></font></div>';
												 
				}

			 } catch(Exception $e){
			 	echo $e;
			 }	

		} else {
			echo "Wrong UserName, password or Security Token.";
	    }
	}
			 
}
?>
<html>
<title>
SalesForce - PHP Integration
</title>
<body bgcolor="#CCFFFF">

<form name="form3" method="post">
<div style="background:#9999FF; color:#000000; height:30px; vertical-align:middle; font-size:22px; font-weight:bold"><center> Insert Lead</center></div><br />
<table align="center">      <tr>
                      <td><b>First Name</b></td>
                      <td><input type="text" name="name" id="name" size="25"></td>
                   </tr>
				   <tr>
                      <td><b>Last Name</b></td>
                      <td><input type="text" name="lastName" id="lastName" size="25"></td>
                   </tr>
                   <tr>
                      <td><b>Mobile No.</b></td>
                      <td><input type="text" name="mobNo" id="mobNo" size="25"></td>
                   </tr>
				   <tr>
                      <td><b>Email</b></td>
                      <td><input type="text" name="email" id="email" size="25"></td>
                   </tr>
                   	<tr>
                      <td colspan="2"><center><input type="submit" value="Insert" name="OK"></center></td>
                  </tr>
				  
</table>
</form>
</body>
</html>

How to do it????