Current location: Hot Scripts Forums » Programming Languages » PHP » newbie question duplicating record


newbie question duplicating record

Reply
  #1 (permalink)  
Old 11-16-08, 10:23 AM
genabit genabit is offline
Newbie Coder
 
Join Date: Nov 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation newbie question duplicating record

Hi I am new to php programming, I have a website that has a mysql database that has the ability to add new rows, edit old rows but what I want to do is to take an existing row, and with a click of a copy link create a duplicate record with a new primary key.

I've used this code snippet to create a new row locally in mysql

update jobs set jobid=0 where jobid=9;
insert into jobs select * from jobs where jobid=0;
update jobs set jobid=9 where jobid=0;

and it does create a new row with a new jobid,

my quandry is how to create a button(link) that will take the jobid variable and
select ( name, description, title, length) from jobs where jobid=\$jobid\
insert (name, description, title, length) into jobs

since jobid is autoincremented and indexed a new record is created I just have a mindblock on how to implement the code via a link. http://www.programmingtalk.com/pt_im...cons/icon4.gif

thanks for any help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-16-08, 11:05 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Specify IGNORE to ignore rows that would cause duplicate-key violations.

http://dev.mysql.com/doc/refman/5.0/...rt-select.html
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 11-16-08, 01:28 PM
landing's Avatar
landing landing is offline
Coding Addict
 
Join Date: Jul 2006
Location: Scotland
Posts: 302
Thanks: 0
Thanked 0 Times in 0 Posts
This is the general idea of what I think you want. Be aware I have excluded any sort of data cleansing and as such the script may be vulnerable to SQL injection.


HTML Code:
<a href="copy.php?jobID=1">Copy Job 1</a>
<a href="copy.php?jobID=2">Copy Job 2</a>
...
copy.php
PHP Code:

// Fetch job based on the jobID passed in the URL

$sql mysql_query("SELECT * FROM `jobs` WHERE `jobid` = '$_GET[jobID]'");
$row mysql_fetch_assoc($sql);

// $row['jobid'] = Job ID
// $row['description'] = Job description

// Now we have the selected job details, we can create a new record
mysql_query("INSERT INTO `jobs` (`jobid`, `description`) VALUES ('$row[jobid]', '$row[description]'");

// If the Job ID is the index and will autoincrement, we don't need to worry about it as it'll be auto-assigned. We can access the new ID using
$newJobID mysql_insert_id(); 
__________________
Always sanitise your data


Best regards
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 11-16-08, 04:44 PM
Biohaz4rd Biohaz4rd is offline
New Member
 
Join Date: Nov 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
If you want PHP to dynamically create the links heres a method I use (edited to fit your needs)

PHP Code:

<?php
$query 
"SELECT * FROM jobs"
$result mysql_query($query) or die('Error : ' mysql_error());
while(
$row mysql_fetch_array($resultMYSQL_ASSOC))
{
echo 
"<a href=\"copy.php?jobID=" $row['$jobid'] . "\">Copy Job" $row['$jobid'] . "</a>";
}
?>

Last edited by Biohaz4rd; 11-16-08 at 04:47 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 11-18-08, 04:13 PM
genabit genabit is offline
Newbie Coder
 
Join Date: Nov 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Thumbs up

ok, here's the final working version, thanks to all of you!!!
Code:
if(isset($_GET['job_copy'])){ // copy the job

$qac = "select jobid from jobs order by jobid desc";
	       $rac = mysql_query($qac) or die(mysql_error(Error2));
	       $ac = mysql_fetch_array($rac);
	       $newjobid = $ac[0] + 1;
		   
$old_jobid = $_GET['old_jobid'];
 $qc = "insert into jobs(jobref,position,category,description,requirements,expiry,postdate,
         benefits,hour,surgicalarea,callpoint,contract,deadline,start,status,tel,fax,cemail, cname ,
         hide,rules,country,education,levels, recruiterid)
         select  jobref,position,category,description,requirements,expiry,postdate,
         benefits,hour,surgicalarea,callpoint,contract,deadline,start,status,tel,fax,cemail, cname ,
         hide,rules,country,education,levels, recruiterid  from jobs where  jobid = $old_jobid" ;
		/*echo $qc = "insert into jobs 
			select * from jobs where
                           jobid = $old_jobid " ;*/

		   $rqc = mysql_query($qc) or die(mysql_error());
	       
		   $q1c = "update jobs set jobid = $newjobid where jobid = '0'";
		   $rq1c = mysql_query($q1c) or die(mysql_error());
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 11-22-08, 01:07 PM
genabit genabit is offline
Newbie Coder
 
Join Date: Nov 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
new issue. - missing variables. - help please.

Hi I am having a new issue in that two of the fields (country and subcounty) are not being copied correctly when I either update the job or copy the job.

Code:
editjob.html

<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td align="left" class="tcat">Job Details</td>
</tr>
<tr>
<td class="tborder">
<?
$q6 = "select * from content where lang = \"$lang\" and section = \"Recruiters\" and title = \"Advertise posting\""; 
$r6 = mysql_query($q6) or die(mysql_error(Error5));
$a6 = mysql_fetch_array($r6);

echo "$a6[content]";
?>
<script language="javascript">
<!--//
var currentTextArea = null
function openEditor(description) {

	// location of edit.php file:
	var editFile = 'edit.php';
	
	currentTextArea = description;

	var edit = window.open(editFile, 'editorWindow', 'width=720, height=450');
	edit.focus();
}
function CheckPostJob()
{
 if(document.PostJobForm.jobref.value=="")
 {
  window.alert('Please enter a job reference number');
  document.PostJobForm.jobref.focus();
  return false;
 }
 if(document.PostJobForm.position.value=="")
 {
  window.alert('Please enter the title of the job posting');
  document.PostJobForm.position.focus();
  return false;
 }
 if(document.PostJobForm.description.value=="")
 {
  window.alert('Please enter a description of the job posting');
  document.PostJobForm.description.focus();
  return false;
 }
}
//-->
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<form method=post name=PostJobForm onsubmit="return CheckPostJob();">
<input type="hidden" name="subcountyhiddenval" id="subcountyhiddenval" />
<input type="hidden" name="subcityhiddenval" id="subcityhiddenval" />
<tr>
<td colspan="2" align="left">

</td>
</tr>
<?
if($message == "Your job vacancy has been successfully updated")
{
echo "
<tr>
<td colspan='2' align='left'><font color='#2E71B7'><b>Your posting has been successfully updated.</b></font>
</td>
</tr>";
}
?>
<tr>
<td colspan="2" align="left">Please enter a reference for the posting you are about to advertise.</td>
</tr>
<tr>
<td width="25%" align="left" valign="top">Job Ref:</td>
<td align="left" valign="top"><input name="jobref" type="text" size="40" value="<?=$a4[jobref]?>"/></td>
</tr>
<tr>
<td colspan="2" align="left">Please enter the contact name so applicants know who to contact when applying for this job posting.</td>
</tr>
<tr>
<tr>
<td align="left" valign="top">Contact Name:</td>
<td align="left" valign="top"><input name="cname" type="text" size="40" value="<?=$a4[cname]?>"/></td>
</tr>
<tr>
<td colspan="2" align="left">Please enter the contact details where you want all applications to be forwarded to.</td>
</tr>
<tr>
<td align="left" valign="top">Email Address:</td>
<td align="left" valign="top"><input name="cemail" type="text" size="40" value="<?=$a4[cemail]?>"/></td>
</tr>
<tr>
<td align="left" valign="top">Telephone:</td>
<td align="left" valign="top"><input name="tel" type="text" size="40" value="<?=$a4[tel]?>"/></td>
</tr>
<tr>
<td align="left" valign="top">Fax: </td>
<td align="left" valign="top"><input name="fax" type="text" size="40" value="<?=$a4[fax]?>">
</td>
</tr>
<tr>
<td colspan="2" align="left">Do you wish for your contact details to be hidden when displaying this job posting.</td>
</tr>
<tr>
<td align="left" valign="top">Hide contact details:</td>
<td align="left" valign="top">
<?
if($a4[hide] == 'Yes')
{
echo "
<input type=radio name=hide value='Yes' checked>Yes
<input type=radio name=hide value='No'>No
";
}
else
{
echo "
<input type=radio name=hide value='Yes'>Yes
<input type=radio name=hide value='No' checked>No
";
}
?>
</td>
</tr>
<tr>
<td colspan="2" align="left">Please enter the title of the posting you are advertising.</td>
</tr>
<tr>
<td align="left" valign="top">Job Title:</td>
<td align="left" valign="top"><input name="position" type="text" size="40" value="<?=$a4[position]?>"/></td>
</tr>
<tr>
<td colspan="2" align="left">Please select a category for this posting.</td>
</tr>
</tr>
<?
if(!empty($a4[category]))
{
?>
<tr>
<td colspan='2' align='left'><b>You previously selected:</b> <font color=red><?=$a4[category]?></font></td>
</tr>
<?
}
?>
<tr>
<td align="left" valign="top">Job Category:</td>
<td align="left" valign="top"><select name=category>
<OPTION VALUE='' selected>Select One</OPTION>
 
<?
$category_query=mysql_query("select * from categories order by category asc");
while ($category_result=mysql_fetch_array($category_query))
{
?>
<option value="<?=$category_result['category']?>" <? if($a1[category]==$category_result['category']){echo '';}?>><?=$category_result['category']?></option>

<?
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="left">Please enter a detailed description for this posting.</td>
</tr>
<tr>
<td align="left" valign="top">Job description:</td>
<td align="left" valign="top">
<textarea cols="40" rows="10" name="description"><?=$a4[description]?></textarea>
<br>
<a href="javascript:openEditor(document.PostJobForm.description)"><b><font color=red>Use HTML Editor</font></b></a>
</td>
</tr>
<tr>
<td align="left" valign="top">Job Requirements:</td>
<td align="left" valign="top">
<textarea cols="40" rows="10" name="requirements"><?=$a4[requirements]?></textarea>
<br>
<a href="javascript:openEditor(document.PostJobForm.requirements)"><b><font color=red>Use HTML Editor</font></b></a>
</td>
</tr>
<tr>
<td align="left" valign="top">Benefits and Compensation:</td>
<td align="left" valign="top">
<textarea cols="40" rows="10" name="benefits"><?=$a4[benefits]?></textarea>
<br>
<a href="javascript:openEditor(document.PostJobForm.benefits)"><b><font color=red>Use HTML Editor</font></b></a>
</td>
</tr>


<tr>
<td colspan="2" align="left">Please select the number of years work experience level the applicant will need.</td>
</tr>
<?
if(!empty($a4[levels]))
{
?>
<tr>
<td colspan='2' align='left'><b>You previously selected:</b> <font color=red><?=$a4[levels]?></font></td>
</tr>
<?
}
?>
<tr>
<td align="left" valign="top">Work Experience:</td>
<td align="left" valign="top">
<select name="levels[]" multiple>
<?php
$level_query=mysql_query("select * from levels order by level asc");
while ($level_result=mysql_fetch_array($level_query))
{
echo '<option value="'.$level_result['level'].'"';
if (strstr($level_result['level'],$level_result['level']))
echo '>'.$level_result['level'].'</option>';
}
?>
</select><br><small>Hold CTRL to select multiple</small>
</td>
</tr>

<tr>
<td colspan="2" align="left">Please select the education level that the applicant will need to have.</td>
</tr>
<?
if(!empty($a4[education]))
{
?>
<tr>
<td colspan='2' align='left'><b>You previously selected:</b> <font color=red><?=$a4[education]?></font></td>
</tr>
<?
}
?>
<tr>
<td align="left" valign="top">Education Level:</td>
<td align="left" valign="top">
<select name="education[]" multiple>
<?php
$level_query=mysql_query("select * from educationlevel order by level asc");
while ($level_result=mysql_fetch_array($level_query))
{
echo '<option value="'.$level_result['level'].'"';
if (strstr($level_result['level'],$level_result['level']))
echo '>'.$level_result['level'].'</option>';
}
?>
</select><br><small>Hold CTRL to select multiple</small>
</td>
</tr>

<tr>
<td colspan="2" align="left">Please select the surgical area.</td>
</tr>
<tr>
<td align="left" valign="top">Surgical Area:</td>
<td align="left" valign="top">
<select name="surgicalarea">
<?
if (!empty($a4[surgicalarea])) 
{
echo "
<OPTION VALUE='$a4[surgicalarea]' selected>$a4[surgicalarea]</OPTION>
";
}
else
{
echo "
<OPTION VALUE='' selected>Select One</OPTION>
";
}
?>
<?php
$level_query=mysql_query("select * from surgicalarea order by level asc");
while ($level_result=mysql_fetch_array($level_query))
{
echo '<option value="'.$level_result['level'].'"';
if (strstr($level_result['level'],$level_result['level']))
echo '>'.$level_result['level'].'</option>';
}
?>
</select>
</td>
</tr>

<tr>
<td colspan="2" align="left">Please select the Call Point.</td>
</tr>
<tr>
<td align="left" valign="top">Call Point:</td>
<td align="left" valign="top">
<select name="callpoint">
<?
if (!empty($a4[callpoint])) 
{
echo "
<OPTION VALUE='$a4[callpoint]' selected>$a4[callpoint]</OPTION>
";
}
else
{
echo "
<OPTION VALUE='' selected>Select One</OPTION>
";
}
?>
<?php
$level_query=mysql_query("select * from callpoint order by level asc");
while ($level_result=mysql_fetch_array($level_query))
{
echo '<option value="'.$level_result['level'].'"';
if (strstr($level_result['level'],$level_result['level']))
echo '>'.$level_result['level'].'</option>';
}
?>
</select>
</td>
</tr>



<tr>
<td colspan="2" align="left">Please indicate whether this is a permanent or temporary posting.</td>
</tr><tr>
<td colspan="2" align="left">Please enter the location where the posting is available.</td>
</tr>
<?
if(!empty($a4[country]))
{
echo "
<tr>
<td colspan='2' align='left'><b>You previously selected:</b> <font color=red>$a4[country]</font></td>
</tr>
";
}
if(!empty($a4[subcounty]))
{
?>
<tr>
<td colspan='2' align='left'><b>You previously selected:</b> <font color=red><?=$a4[subcounty]?></font></td>
</tr>
<?
}
?>
<tr>
<td align="left" valign="top">Select Location:</td>
<td><select name=country[] multiple>
<?
$country_query=mysql_query("select * from countries order by country asc");
while ($country_result=mysql_fetch_array($country_query))
{
?>
<option value="<?=$country_result['country']?>" <? if($a1[country]==$country_result['country']){echo '';}?>><?=$country_result['country']?></option>

<?
}
?>
</select><br><small>Hold CTRL to select multiple</small>
</td>
</tr>
<tr>
<td align="left" valign="top">Cities:</td>
<td align="left" valign="top"><textarea name="subcounty" rows="2" cols="30"><?=$a4[subcounty]?></textarea></td>
</tr>
<tr>
<td align="left" valign="top" colspan="2">Please indicate how you want potential applicants to apply for this job posting. If you leave this section blank, the system will use the default application system where applications will be forwarded to your specific email address.</td>
</tr>
<tr>
<td align="left" valign="top">Application Rules:</td>
<td align="left" valign="top"><textarea name="rules" rows="3" cols="45"><?=$a4[rules]?></textarea></td>
</tr>
<tr>
<td align="center" colspan="2">
<?
if(!empty($a4[country]))
{
echo "<input type='hidden' name='country2' value='$a4[country]'>";
}
if(!empty($a4[category]))
{
echo "<input type='hidden' name='category2' value='$a4[category]'>";
}
if(!empty($a4[levels]))
{
echo "<input type='hidden' name='levels2' value='$a4[levels]'>";
}
if(!empty($a4[education]))
{
echo "<input type='hidden' name='education2' value='$a4[education]'>";
}
?>
<input name="submit" type="submit" value="Submit" />&nbsp;<input name="submitcopy" type="submit" value="Copy Job" /></td>
</tr>
</form>
</table>

</td>
</tr>
</table>
Code:
PHP Code:

editjob.php

<?
include_once "accesscontrol.php";
include_once "../lang/$lang/header.html";
include_once "../lang/$lang/employers/side1.html";

if(isset($submit))
{
           $subcounty base64_decode($_REQUEST['subcountyhiddenval']);

  $q3 "update jobs set
         jobref = \"$jobref\",
     position = \"$position\",
     category = \"$category\",
     description = \"$description\",
         hour = \"$hour\", 
         contract = \"$contract\",
         deadline = \"$deadline\",
         start = \"$start\",
     salary = \"$salary\",
         status = \"0\",
         tel = \"$tel\",
         cemail = \"$cemail\",
         cname = \"$cname\",
         hide = \"$hide\", 
         rules = \"$rules\"
         where jobid = \"$jobid\"";
  $r3 =  mysql_query($q3) or die(mysql_error());

if(!empty($country))
{
           $q5 "update jobs set
                  country = \"$country\",
                  subcounty = \"$subcounty\"
                      where jobid = \"$jobid\"";

           $r5 =  mysql_query($q5) or die(mysql_error(Error3));
}
else
{

           $q5 "update jobs set
                  country = \"$country2\",
                  subcounty = \"$subcounty2\",
                  subcity = \"$subcity2\"
                      where jobid = \"$jobid\"";

           $r5 =  mysql_query($q5) or die(mysql_error(Error3));
}

if(!empty($category))
{
           $q5 "update jobs set
                  category = \"$category\"
                      where jobid = \"$jobid\"";

           $r5 =  mysql_query($q5) or die(mysql_error(Error3));
}
else
{
           $q5 "update jobs set
                  category = \"$category2\"
                      where jobid = \"$jobid\"";

           $r5 =  mysql_query($q5) or die(mysql_error(Error3));
}



$q4 "select * from jobs where jobid = \"$jobid\" ";
$r4 mysql_query($q4) or die(mysql_error());
$a4 mysql_fetch_array($r4);

$message 'Your job vacancy has been successfully updated';
include "../lang/$lang/employers/editjob.html";
include_once "../lang/$lang/employers/side2.html";
include "../lang/$lang/footer.html";
exit;
}
else
{
$q4 "select * from jobs where jobid = \"$jobid\" ";
$r4 mysql_query($q4) or die(mysql_error());
$a4 mysql_fetch_array($r4);

include_once "../lang/$lang/employers/editjob.html";
include_once "../lang/$lang/employers/side2.html";
}
include_once "../lang/$lang/footer.html";
?>:crying: :confused:
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 11-23-08, 02:12 PM
landing's Avatar
landing landing is offline
Coding Addict
 
Join Date: Jul 2006
Location: Scotland
Posts: 302
Thanks: 0
Thanked 0 Times in 0 Posts
Hi - I would re post your PHP code and format correctly. A string of jargon won't be much use to anyone.
__________________
Always sanitise your data


Best regards
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 11-23-08, 02:20 PM
genabit genabit is offline
Newbie Coder
 
Join Date: Nov 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
reformatted php code

PHP Code:

<?

include_once "accesscontrol.php";
include_once 
"../lang/$lang/header.html";
include_once 
"../lang/$lang/recruiters/side1.html";

if(isset(
$submit) || isset($submitcopy))
{

if (
is_array($country))
 {
 
$country implode(", " $country);
 }
 if (
is_array($levels))
 {
 
$levels implode(", " $levels);
 }
 if (
is_array($education))
 {
 
$education implode(", " $education);
 }
//====================================== 
if(isset($submitcopy)){ // copy a new job
            
$EXday date('d'mktime(0,0,0,0date(d) + 300));
           
$EXmonth date('m'mktime(0,0,0date(m), date(d) + 300));
           
$EXyear date('Y'mktime(0,0,0,date(m) ,date(d) + 30date(Y)));

           
$EXday1 date('d'mktime(0,0,0,0date(d) + 00));
           
$EXmonth1 date('m'mktime(0,0,0date(m), date(d) + 00));
           
$EXyear1 date('Y'mktime(0,0,0,date(m) ,date(d) + 0date(Y)));

           
$q3 "insert into jobs set
               jobref = \"
$jobref\",
           recruiterid = \"
$a1[recruiterid]\",
           position = \"
$position\",
           deadline = \"
$deadline\",
           category = \"
$category\",
               start = \"
$start\", 
           description = \"
$description\",
           requirements = \"
$requirements\",
           benefits = \"
$benefits\",
               hour = \"
$hour\", 
               surgicalarea = \"
$surgicalarea\", 
               callpoint = \"
$callpoint\", 
               levels = \"
$levels\", 
               education = \"
$education\", 
               contract = \"
$contract\",
           expiry = \"
$EXmonth/$EXday/$EXyear\", 
               tel = \"
$tel\",
         fax = \"
$fax\",
               cemail = \"
$cemail\",
               cname = \"
$cname\",
               hide = \"
$hide\", 
               rules = \"
$rules\",
               postdate = \"
$EXmonth1/$EXday1/$EXyear1\"";

           
$message 'Your job vacancy has been successfully copied';
           
$r3 mysql_query($q3) or die(mysql_error(Error3));

if(!empty(
$country))
{
           
$q5 "update jobs set
                  country = \"
$country\",
                  subcounty = \"
$subcounty\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}
else
{

           
$q5 "update jobs set
                  country = \"
$country2\",
                  subcounty = \"
$subcounty2\",
                  subcity = \"
$subcity2\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}

if(!empty(
$subcounty))
{
           
$q5 "update jobs set
                  subcounty = \"
$subcounty\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}
else
{

           
$q5 "update jobs set
                  subcounty = \"
$subcounty2\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}
    
if(!empty(
$category))
{
           
$q5 "update jobs set
                  category = \"
$category\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}
else
{
           
$q5 "update jobs set
                  category = \"
$category2\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}

if(!empty(
$education))
{
           
$q5 "update jobs set
                  education = \"
$education\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}
else
{
           
$q5 "update jobs set
                  education = \"
$education2\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}

if(!empty(
$levels))
{
           
$q5 "update jobs set
                  levels = \"
$levels\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}
else
{
           
$q5 "update jobs set
                  levels = \"
$levels2\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}
       
?>
<script type="text/javascript">
document.location.href = 'manage.php';
</script>
<?php           
    
die();
        
//   header('Location: manage.php'); die();

}
//======================================
 

  
$q3 "update jobs set
         jobref = \"
$jobref\",
     position = \"
$position\",
     category = \"
$category\",
     description = \"
$description\",
     requirements = \"
$requirements\",
     benefits = \"
$benefits\",
         hour = \"
$hour\", 
         surgicalarea = \"
$surgicalarea\", 
         callpoint = \"
$callpoint\", 
         contract = \"
$contract\",
         deadline = \"
$deadline\",
         start = \"
$start\",
         status = \"0\",
         tel = \"
$tel\",
         fax = \"
$fax\",
         cemail = \"
$cemail\",
         cname = \"
$cname\",
         hide = \"
$hide\", 
         rules = \"
$rules\"
         where jobid = \"
$jobid\"";
  
$r3 =  mysql_query($q3) or die(mysql_error());

if(!empty(
$country))
{
           
$q5 "update jobs set
                  country = \"
$country\",
                  subcounty = \"
$subcounty\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}
else
{

           
$q5 "update jobs set
                  country = \"
$country2\",
                  subcounty = \"
$subcounty2\",
                  subcity = \"
$subcity2\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}

if(!empty(
$category))
{
           
$q5 "update jobs set
                  category = \"
$category\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}
else
{
           
$q5 "update jobs set
                  category = \"
$category2\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}

if(!empty(
$education))
{
           
$q5 "update jobs set
                  education = \"
$education\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}
else
{
           
$q5 "update jobs set
                  education = \"
$education2\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}

if(!empty(
$levels))
{
           
$q5 "update jobs set
                  levels = \"
$levels\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}
else
{
           
$q5 "update jobs set
                  levels = \"
$levels2\"
                      where jobid = \"
$jobid\"";

           
$r5 =  mysql_query($q5) or die(mysql_error(Error3));
}



$q4 "select * from jobs where jobid = \"$jobid\" ";
$r4 mysql_query($q4) or die(mysql_error());
$a4 mysql_fetch_array($r4);

$message 'Your job vacancy has been successfully updated';
include 
"../lang/$lang/recruiters/editjob.html";
include_once 
"../lang/$lang/recruiters/side2.html";
include 
"../lang/$lang/footer.html";
exit;
}
else
{
$q4 "select * from jobs where jobid = \"$jobid\" ";
$r4 mysql_query($q4) or die(mysql_error());
$a4 mysql_fetch_array($r4);

include_once 
"../lang/$lang/recruiters/editjob.html";
include_once 
"../lang/$lang/recruiters/side2.html";
}
include_once 
"../lang/$lang/footer.html";
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 11-23-08, 02:22 PM
genabit genabit is offline
Newbie Coder
 
Join Date: Nov 2008
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Not sure why it garbled that previously, maybe a gremlin on the internet? lol
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 11-23-08, 04:59 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Code:
if(isset($_GET['job_copy'])){ // copy the job

$qac = "select jobid from jobs order by jobid desc";
	       $rac = mysql_query($qac) or die(mysql_error(Error2));
	       $ac = mysql_fetch_array($rac);
	       $newjobid = $ac[0] + 1;
		   
$old_jobid = $_GET['old_jobid'];
Please be aware that this code, specifically the unfiltered GET statements, is a recipe for disaster. As it stands, a malicious user could pass in a SQL statement (or other code) that would compromise your server completely. There isn't anything they couldn't do once they had control. And your biggest fear isn't an individual user, it's bots that scan the web for forms and then start "fuzzing" the forms automatically, looking for exploits and vulnerabilities. This happens all the time and I can just about guarantee you that your site will be hacked before long if you ran that code as shown.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
General newbie code question Shelby PHP 4 01-15-08 12:00 AM
Hello Another newbie, with a question WannabeCoder New Members & Introductions 0 10-15-06 11:05 PM
Hi - newbie with specific question Seamoose New Members & Introductions 0 04-01-06 08:08 PM
newbie HTML question mrlocom HTML/XHTML/XML 8 04-11-05 01:07 PM
NEWBIE QUESTION: Forms - Assigning Values to Variables jenf JavaScript 1 07-23-04 04:36 PM


All times are GMT -5. The time now is 01:49 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.