<?php
session_start();
include("header.php");

if(trim($_SESSION['accountName'])=="" &&  trim($_SESSION['accountID'])=="" && trim($_SESSION['pgid'])!="i3g3e3nious7")
{
	echo '<script>';
	echo 'location.replace("index.php");';
	echo '</script>';
}
else
{


if($_POST['eaction']=='UPDATE')
{
	if($_POST['pid']=="")
		$errmsg = $errmsg."PayPal ID field is empty.<br/>";

	if(trim($errmsg)=="")
	{
		$ins=@mysql_query("update paypal set paypal_id='".$_POST['pid']."' where slno='".$_POST['usid']."'");

		$errmsg = "You have successfully updated your Paypal Id.";

		$_POST['pid']="";

	}
}

if($_GET['sid']!="")
{
	$selp=@mysql_query("select * from paypal where status='1' and slno='".$_GET['sid']."'");
	$row=@mysql_fetch_array($selp);

	$pid=$row['paypal_id'];
}
else
{
	$pid=$_POST['pid'];
}

?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td></td>
		<td align="center" class="fs14 black"><u><b>Paypal Id</b></u></td></tr>
	<tr>
		<td width="200" class="fs12" valign="top">
		<?php
		include("sidemenu.php");
		?>
		</td>
		<td width="700" class="fs12" valign="top">
		<form name='paypal' method='post' action='paypalid.php'>
			<table width="100%" cellpadding="1" cellspacing="1" border="0">
				<tr><td colspan="2"><hr /></td></tr>
				<tr>
					<td>&nbsp;&nbsp;Paypal ID</td>
					<td>&nbsp;&nbsp;<input type='text' name='pid' value='<?=$pid?>' class='formInput'/></td>
				</tr>
				
				<tr>
					<td colspan='2' align='center'><input type='submit' name='eaction' value='UPDATE'/><input type='hidden' name='usid' value='<?=$_GET['sid']?>'/></td>
				</tr>
				

				<tr><td colspan="2"><hr /></td></tr>
				<tr valign='top' align='center'><td colspan='2'><?=$errmsg?></td></tr>
				<tr><td colspan="2"><hr /></td></tr>
				
				<tr>
					<td colspan='2'>
						<table border='0' cellpadding='1' cellspacing='1' width='100%'>
						<tr>
							<td align="center" class="fs14 black" colspan='3'><u><b>View Record</b></u></td></tr>
						</tr>
						<tr><td colspan="3"><hr /></td></tr>
							<tr>
								<td>Sl.No.</td>
								<td>PayPal ID</td>
								<td>Options</td>
							</tr>
							<?php
								$sel=@mysql_query("select * from paypal where status='1'");
								$cnt=@mysql_num_rows($sel);
								if($cnt>0)
								{
									$rs=@mysql_fetch_array($sel);
									
										echo '<tr>';
										echo '<td>1</td>';
										echo '<td>'.$rs['paypal_id'].'</td>';
										echo '<td><a href="paypalid.php?sid='.$rs['slno'].'">edit</a></td>';
										echo '</tr>';
									
								}
								else
								{
									echo '<tr><td></td></tr>';
								}
							?>
							
						</table>
					</td>
				</tr>
				
			</table>
		</form>
		</td>
	</tr>
</table>
</td>
</tr>
<?php
include("footer.php");
}
?>
