Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

Would anyone be so kind to convert my php into asp please?

Greatly appreciated.
James

PHP
<?
$objConnect = mysql_connect("***","***","***") or die(mysql_error());
$objDB = mysql_select_db("***");

//*** Add ***//
if($_POST["hdnCmd"] == "Add")
{
$strSQL = "INSERT INTO xxxxxxx ";
$strSQL .="(ID,StartDateTime,EndDateTime,Name,Email,Telephone,SMS,Sex) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtAddID"]."','".$_POST["txtAddStart"]."','".$_POST["txtAddEnd"]."','".$_POST["txtAddName"]."' ";
$strSQL .=",'".$_POST["txtAddEmail"]."' ";
$strSQL .=",'".$_POST["txtAddTelephone"]."','".$_POST["txtAddSMS"]."' ";
$strSQL .=",'".$_POST["txtAddSex"]."') ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Save [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}

//*** Update ***//
if($_POST["hdnCmd"] == "Update")
{
$strSQL = "UPDATE xxxxxxx SET ";
$strSQL .="ID = '".$_POST["txtEditID"]."' ";
$strSQL .=",StartDateTime = '".$_POST["txtEditStart"]."' ";
$strSQL .=",EndDateTime = '".$_POST["txtEditEnd"]."' ";
$strSQL .=",Name = '".$_POST["txtEditName"]."' ";
$strSQL .=",Email = '".$_POST["txtEditEmail"]."' ";
$strSQL .=",Telephone = '".$_POST["txtEditTelephone"]."' ";
$strSQL .=",SMS = '".$_POST["txtEditSMS"]."' ";
$strSQL .=",Sex = '".$_POST["txtEditSex"]."' ";
$strSQL .="WHERE ID = '".$_POST["hdnEditID"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Update [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}

//*** Delete ***//
if($_GET["Action"] == "Del")
{
$strSQL = "DELETE FROM xxxxxxx ";
$strSQL .="WHERE ID = '".$_GET["CusID"]."' ";
$objQuery = mysql_query($strSQL);
if(!$objQuery)
{
echo "Error Delete [".mysql_error()."]";
}
//header("location:$_SERVER[PHP_SELF]");
//exit();
}

$strSQL = "SELECT * FROM xxxxxxx order by ID";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<form name="frmMain" method="post" action="<?=$_SERVER["PHP_SELF"];?>">
<!-- Headings -->
<input type="hidden" name="hdnCmd" value="">
<table>
<tr>
<th>ID<br><sub>Max of 6 Characters</sub></th>
<th>Start Date & Time<br><sub>yyyy-mm-dd hh:mm:ss</sub></th>
<th>End Date & Time<br><sub>yyyy-mm-dd hh:mm:ss</sub></th>
<th>Name<br><sub>Full Name</sub></th>
<th>Email<br><sub>All lower case<br>In the format of xxx@xxx.xxx</sub></th>
<th>Telephone<br><sub>No Spaces<br>(11 digits including area code)</sub></th>
<th>SMS<br><sub>No Spaces<br>(11 digits only)</sub></th>
<th>Him or Her<br><sub>Him or Her Only</sub></th>
<th colspan="2">Select Option<br><sub>Add, Edit or Delete</sub></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>

<?
if($objResult["ID"] == $_GET["CusID"] and $_GET["Action"] == "Edit")
{
?>
<!-- In Edit Mode -->
<tr>
<td>
<input type="text" name="txtEditID" value="<?=$objResult["ID"];?>">
<input type="hidden" name="hdnEditID" value="<?=$objResult["ID"];?>">
</td>
<td><input type="text" name="txtEditStart" value="<?=$objResult["StartDateTime"];?>"></td>
<td><input type="text" name="txtEditEnd" value="<?=$objResult["EndDateTime"];?>"></td>
<td><input type="text" name="txtEditName" value="<?=$objResult["Name"];?>"></td>
<td><input type="text" name="txtEditEmail" value="<?=$objResult["Email"];?>"></td>
<td><input type="text" name="txtEditTelephone" value="<?=$objResult["Telephone"];?>"></td>
<td><input type="text" name="txtEditSMS" value="<?=$objResult["SMS"];?>"></td>
<td><input type="text" name="txtEditSex" value="<?=$objResult["Sex"];?>"></td>
<td colspan="2" align="center">
<input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();">
<input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?=$_SERVER["PHP_SELF"];?>';">
</td>
</tr>
<?
}
else
{
?>
<!-- In View Mode -->
<tr>
<td><?=$objResult["ID"];?></td>
<td><?=$objResult["StartDateTime"];?></td>
<td><?=$objResult["EndDateTime"];?></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Email"];?></td>
<td><?=$objResult["Telephone"];?></td>
<td><?=$objResult["SMS"];?></td>
<td><?=$objResult["Sex"];?></td>
<td><a href="<?=$_SERVER["PHP_SELF"];?>?Action=Edit&CusID=<?=$objResult["ID"];?>">Edit</a></td>
<td><a href="java<!-- no -->script:if(confirm('Confirm Delete?')==true){window.location='<?=$_SERVER["PHP_SELF"];?>?Action=Del&CusID=<?=$objResult["ID"];?>';}">Delete</a></td>
</tr>
<?
}
?>
<?
}
?>
<!-- In Add Mode -->
<tr>
<td><input type="text" name="txtAddID"></td>
<td><input type="text" name="txtAddStart"></td>
<td><input type="text" name="txtAddEnd"></td>
<td><input type="text" name="txtAddName"></td>
<td><input type="text" name="txtAddEmail"></td>
<td><input type="text" name="txtAddTelephone"></td>
<td><input type="text" name="txtAddSMS"></td>
<td><input type="text" name="txtAddSex"></td>
<td colspan="2" align="center">
<input name="btnAdd" type="button" id="btnAdd" value="Add" OnClick="frmMain.hdnCmd.value='Add';frmMain.submit();">
</td>
</tr>
</table>
</form>
<?
mysql_close($objConnect);
?>
Posted
Updated 25-Jan-13 0:26am
v2
Comments
bbirajdar 25-Jan-13 6:29am    
You have posted it at the wrong place. You need to post it here ^
MT_ 25-Jan-13 6:42am    
Well J3ffers, you need to outsource to someone. At CP, you ask for help in case you are stuck somewhere.

Convert PHP to ASP[^] online convert from here
 
Share this answer
 
Comments
J3ffers 25-Jan-13 6:35am    
Thanks Abhishek, I've tried that and it spits out a few errors.
Abhishek Pant 25-Jan-13 6:53am    
Insert the id labels directly on that code.I think that will resolve your error.
Paid someone.. not really was just trying my luck as I have little to no experience in asp.. cheers anyway guys..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900