Script Re-writing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Script Re-writing

Post by mohson »

Ok guys bare with me -

The code below is what I use to edit and update records.

When a user clicks the edit button in my 'Display records' page a form is loaded that can be updated with new details and saved.

The problem is - the way this code is currently written - if I try to make any formatting changes whatsoever my screen just goes blank its like im intefering with the positions of the (')s inadvertantly,

could someone perhaps show me a way of writing this without massively overhauling the code.

Thanks in advance

Code: Select all

/* Connecting, selecting database */
$link = mysql_connect("xxx", "xxxx", "xxx")
   or die("Could not connect : " . mysql_error());
echo "";
mysql_select_db("contact_management_system") or die("Could not select database");
	
		if(isset($_GET['person_id'])){
			$person_id=$_GET['person_id'];
		}

		if ($_POST['Submit'] == 'Save'){

			foreach ($_POST as $formName => $phpName){
				$$formName = $phpName;
			}
			
					$sql ="UPDATE people SET "
					. " salutation='"	.$salutation."'," 
					. " firstname='"	.$firstname	."'," 
					. " surname='"		.$surname."'," 
					. " organisation='" .$organisation	."'," 
					. " role='"			.$role."'," 
					. " address1='"	.	$address1."'," 
					. " address2='" .$address2."'," 
					. " city='" .$city."'," 
					. " telephone='" .$telephone."'," 
					. " mobile='" .	$mobile	."'," 
					. " fax='" .$fax."'," 
					. " dateoflastcontact='" .$dateoflastcontact."',"
					. " datecontactagain='" .$datecontactagain."',"
					. " notes='" .$notes."',"
					. " email='" .$email."',"
					. " org_id='" .	$org_id	."'"
					. " WHERE person_id='" . $person_id."'";

			echo "<br><div align=center><br>";
			mysql_query($sql) or die('could not insert' . mysql_error());

			echo  "		<div align=left><table width=70% border=1 cellpadding=10 align=center>"
				. "		<tr>"
				. "			<td width=40%>"
				. "					<font face=arial size=2><b>"
				. "					Salutation"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $salutation . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					Firstname"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $firstname . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					Surname"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $surname . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					Organisation"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $organisation . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					Role"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $role . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					Address 1"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $address1 . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					Address 2"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $address2 . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					City"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $city . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					Postcode"
				. "					</font>"
				. "				</td>"
				. "					<td>"
				. "					<font face=arial size=2>"
				. "					" . $postcode . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "						Telephone"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $telephone . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					Mobile"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $mobile . "</font>"
				. "				</td>"
				. "			</tr>"
				."			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					Fax"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $fax . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					Last Contact"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $dateoflastcontact . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					Contact Again"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $datecontactagain . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					E-mail"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $email . "</font>"
				. "				</td>"
				. "			</tr>"
				. "			<tr>"
				. "				<td>"
				. "					<font face=arial size=2><b>"
				. "					OID"
				. "					</font>"
				. "				</td>"
				. "				<td>"
				. "					<font face=arial size=2>"
				. "					" . $org_id . "</font>"
				. "				</td>"
				. "			</tr>"
				. "		</table>"; 
		}
		
		$sql = "SELECT * FROM people WHERE person_id='" . $person_id . "'";
			//echo "<br><div align=center>" . $sql . "<br>";
			echo "<br><div align=center><br>";
			$memb = mysql_query($sql) or die(mysql_error());
			$row = mysql_fetch_array($memb);

			echo  "\n"
				. "		</div>\n"
				. "		<form name=form2 method=post action=editpeople.html?person_id=" . $person_id . ">\n"
				. "			<table width=70% border=1 cellpadding=10 align=center>\n" 
				. "				<tr>\n"
				. "					<td width=40%>\n"
				. "						<font face=arial size=2><b>\n"
				. "						Salutation\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=salutation type=text id=salutation value='" . $row['salutation'] . "'></font>\n"
				. "				<tr>\n"
				. "					<td width=40%>\n"
				. "						<font face=arial size=2><b>\n"
				. "						First Name\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=firstname type=text id=firstname value='" . $row['firstname'] . "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						Surname\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=surname type=text id=surname value='" . $row['surname'] . "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						Organisation\n"
				. "						</font>\n"
				. "						</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=organisation type=text id=organsation value='" . $row['organisation'] . "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						Role \n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=role type=text id=role value='" . 
				$row['role']		. "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						Address (1)\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=address1 type=text id=address1 value='" . $row['address1'] . "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						Address(2)\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=address2 type=text id=address2 value='" . $row['address2'] . "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						City\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=city type=text id=city value='" . 
				$row['city']	. "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						Postcode\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=postcode type=text id=postcode value='" . $row['postcode'] . "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						Telephone\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=telephone type=text id=telephone value='" . $row['telephone'] . "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						Mobile\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=mobile type=text id=mobile value='" . 
				$row['mobile'] . "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						Fax\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=fax type=text id=fax value='" . 
				$row['fax'] . "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						Last Contact\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=dateoflastcontact type=text id=dateoflastcontact 								value='" . 
				$row['dateoflastcontact'] . "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						Contact Again\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=datecontactagain type=text id=datecontactagain 									value='" . 
				$row['datecontactagain'] . "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						E-mail\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=email type=text id=email value='" . 
				$row['email'] . "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td>\n"
				. "						<font face=arial size=2><b>\n"
				. "						OID\n"
				. "						</font>\n"
				. "					</td>\n"
				. "					<td>\n"
				. "						<font face=arial size=2>\n"
				. "						<input name=org_id type=text id=org_id value='" . 
				$row['org_id'] . "'></font>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td colspan=2>\n"
				. "						&nbsp\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "				<tr>\n"
				. "					<td colspan=2 align=center>\n"
				. "						<input type=reset name=Reset value=Cancel>\n"
				. "						<input type=submit name=Submit
				value=Save>\n"
				. "					</td>\n"
				. "				</tr>\n"
				. "			</table>\n"
				. "		</form>\n";
	//	}
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

something like this would be easier.

On the first table please go through and change your variables from

$salutation

to

<?php echo $salutation ?>

There was too many and couldn't be bothered to do it myself

Code: Select all

<?php

/* Connecting, selecting database */
$link = mysql_connect("xxx", "xxxx", "xxx")
   or die("Could not connect : " . mysql_error());
echo "";
mysql_select_db("contact_management_system") or die("Could not select database");
    
if(isset($_GET['person_id'])){
	$person_id=$_GET['person_id'];
}
 
if ($_POST['Submit'] == 'Save'){
 
	foreach ($_POST as $formName => $phpName){
		$$formName = $phpName;
	}
            
$sql = "UPDATE people SET
		salutation='".$salutation."',
		firstname='".$firstname    ."',
        surname='".$surname."',
       	organisation='".$organisation    ."',
        role='".$role."',
        address1='".$address1."',
        address2='".$address2."',
        city='".$city."',
        telephone='".$telephone."',
        mobile='".$mobile."',
        fax='".$fax."',
        dateoflastcontact='".$dateoflastcontact."',
        datecontactagain='".$datecontactagain."',
        notes='".$notes."',
        email='".$email."',
        org_id='".$org_id."'
        WHERE person_id='".$person_id."'";
		
mysql_query($sql) or die('could not insert' . mysql_error());
?>
 
<br><div align=center><br>
            
 
<div align=left><table width=70% border=1 cellpadding=10 align=center>
        <tr>
            <td width=40%>
                    <font face=arial size=2><b>
                    Salutation
                    </font>
                </td>
                <td>
                    <font face=arial size=2>
                    $salutation </font>
                </td>
            </tr>
            <tr>
                <td>
                    <font face=arial size=2><b>
                    Firstname
                    </font>
               </td>
                <td>
                    <font face=arial size=2>
                   $firstname </font>
                </td>
            </tr>
            <tr>
                                <td>
                                    <font face=arial size=2><b>
                                    Surname
                                    </font>
                                </td>
                                <td>
                                    <font face=arial size=2>
                                    $surname </font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <font face=arial size=2><b>
                                    Organisation
                                    </font>
                                </td>
                                <td>
                                    <font face=arial size=2>
                                    $organisation </font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <font face=arial size=2><b>
                                    Role
                                    </font>
                                </td>
                                <td>
                                    <font face=arial size=2>
                                    $role </font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <font face=arial size=2><b>
                                    Address 1
                                    </font>
                                </td>
                                <td>
                                    <font face=arial size=2>
                                    $address1 </font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <font face=arial size=2><b>
                                    Address 2
                                    </font>
                                </td>
                                <td>
                                    <font face=arial size=2>
                                    $address2 </font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <font face=arial size=2><b>
                                    City
                                    </font>
                                </td>
                                <td>
                                    <font face=arial size=2>
                                    $city </font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <font face=arial size=2><b>
                                    Postcode
                                    </font>
                                </td>
                                    <td>
                                    <font face=arial size=2>
                                    $postcode </font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <font face=arial size=2><b>
                                        Telephone
                                    </font>
                                </td>
                                <td>
                                    <font face=arial size=2>
                                    $telephone </font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <font face=arial size=2><b>
                                    Mobile
                                    </font>
                                </td>
                                <td>
                                    <font face=arial size=2>
                                    $mobile </font>
                                </td>
                            </tr>
                      <tr>
                                <td>
                                    <font face=arial size=2><b>
                                    Fax
                                    </font>
                                </td>
                                <td>
                                    <font face=arial size=2>
                                    $fax </font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <font face=arial size=2><b>
                                    Last Contact
                                    </font>
                                </td>
                                <td>
                                    <font face=arial size=2>
                                    $dateoflastcontact </font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <font face=arial size=2><b>
                                    Contact Again
                                    </font>
                                </td>
                                <td>
                                    <font face=arial size=2>
                                    $datecontactagain </font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <font face=arial size=2><b>
                                    E-mail
                                    </font>
                                </td>
                                <td>
                                    <font face=arial size=2>
                                    $email </font>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <font face=arial size=2><b>
                                    OID
                                    </font>
                                </td>
                                <td>
                                    <font face=arial size=2>
                                    $org_id </font>
                                </td>
                            </tr>
                        </table>
<?php
}
        
        $sql = "SELECT * FROM people WHERE person_id='" . $person_id ."'";
		
		$memb = mysql_query($sql) or die(mysql_error());
        $row = mysql_fetch_array($memb);
		
?>
<br><div align=center><?php echo $sql; ?><br>
<br><div align=center><br>
            
 

                        </div>
                        <form name=form2 method=post action=editpeople.html?person_id=<?php echo $person_id; ?> >
                            <table width=70% border=1 cellpadding=10 align=center> 
                                <tr>
                                    <td width=40%>
                                        <font face=arial size=2><b>
                                        Salutation
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=salutation type=text id=salutation value=<?php echo $row['salutation'] ; ?>></font>
                                <tr>
                                    <td width=40%>
                                        <font face=arial size=2><b>
                                        First Name
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=firstname type=text id=firstname value=<?php echo $row['firstname'] ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        Surname
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=surname type=text id=surname value=<?php echo $row['surname'] ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        Organisation
                                        </font>
                                        </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=organisation type=text id=organsation value=<?php echo $row['organisation'] ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        Role 
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=role type=text id=role value=<?php echo 
                $row['role']        ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        Address (1)
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=address1 type=text id=address1 value=<?php echo $row['address1'] ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        Address(2)
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=address2 type=text id=address2 value=<?php echo $row['address2'] ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        City
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=city type=text id=city value=<?php echo 
                $row['city']    ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        Postcode
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=postcode type=text id=postcode value=<?php echo $row['postcode'] ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        Telephone
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=telephone type=text id=telephone value=<?php echo $row['telephone'] ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        Mobile
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=mobile type=text id=mobile value=<?php echo 
                $row['mobile'] ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        Fax
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=fax type=text id=fax value=<?php echo 
                $row['fax'] ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        Last Contact
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=dateoflastcontact type=text id=dateoflastcontact                                 value=<?php echo 
                $row['dateoflastcontact'] ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        Contact Again
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=datecontactagain type=text id=datecontactagain                                     value=<?php echo 
                $row['datecontactagain'] ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        E-mail
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=email type=text id=email value=<?php echo 
                $row['email'] ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <font face=arial size=2><b>
                                        OID
                                        </font>
                                    </td>
                                    <td>
                                        <font face=arial size=2>
                                        <input name=org_id type=text id=org_id value=<?php echo 
                $row['org_id'] ; ?>></font>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan=2>
                                        &nbsp
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan=2 align=center>
                                        <input type=reset name=Reset value=Cancel>
                                        <input type=submit name=Submit
                value=Save>
                                    </td>
                                </tr>
                            </table>
                        </form>
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Long live loops :p But i remember that i've already hinted you that you could reduce a lot of your code...

It's braindead to accept the posted values.... Without performing validation... At least perform a mysql_escape_string or something like that...

Code: Select all

$names = array('organisation', 'name', 'surname');
foreach($names as $name)
{
  echo "<div>";
  ${$name} = $_POST['name'];
  echo ${$name};
  echo "</div>";
}
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

pimptatsic - what do u mean by changing on your firstable
timvw - can you explain to me how I could make this code much simpler?
mohson
Forum Contributor
Posts: 372
Joined: Thu Dec 02, 2004 6:58 am
Location: London

Post by mohson »

Ok guys im getting slightly confused - could someone please advise me concerning the first post on this thread.

I would really appreciate it if someone could bare with me on this one and try and explain how I could make this code a lot simpler.
Post Reply