I have a php page showing records from an sql database, when the user clicks on a link they are taken to a detail page with more info etc.

All of this works fine - the issue is that I wiould like uses to be able to submit a form from this page with a file attached.

I have the form as an include, with any data being entered into the form being sent to my email - this is fine.

The problem occurs with some hidden fields with details from the recordset not being displayed,

I don't know if this makes any sense so if anybody needs further info please let me know.

The statement "The problem occurs with some hidden fields with details from the recordset not being displayed,"

Is that hidden fields data contains in include file which you are talking about..

Then how you will get the recordset(DB) data in an include file, while including the file you just need to assign an id or something to fetch the data from the DB and make a form in the include file to display....

Hope it helps you

If you don't get what I said
post your related code in the forum, I will tell you


I have a php page showing records from an sql database, when the user clicks on a link they are taken to a detail page with more info etc.

All of this works fine - the issue is that I wiould like uses to be able to submit a form from this page with a file attached.

I have the form as an include, with any data being entered into the form being sent to my email - this is fine.

The problem occurs with some hidden fields with details from the recordset not being displayed,

I don't know if this makes any sense so if anybody needs further info please let me know.

Hi Sai

Thanks for the quick response.

The code for the page with the include is below - please let me know if you need further info:

<?php if (isset($_GET['posted_by'])) 
	$adv = $_GET['posted_by'];?>
<?php require_once('Connections/jobs.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$maxRows_Hot_Jobs = 5;
$pageNum_Hot_Jobs = 0;
if (isset($_GET['pageNum_Hot_Jobs'])) {
  $pageNum_Hot_Jobs = $_GET['pageNum_Hot_Jobs'];
}
$startRow_Hot_Jobs = $pageNum_Hot_Jobs * $maxRows_Hot_Jobs;

mysql_select_db($database_jobs, $jobs);
$query_Hot_Jobs = "SELECT * FROM jobs WHERE hot_job = 1 ORDER BY created DESC";
$query_limit_Hot_Jobs = sprintf("%s LIMIT %d, %d", $query_Hot_Jobs, $startRow_Hot_Jobs, $maxRows_Hot_Jobs);
$Hot_Jobs = mysql_query($query_limit_Hot_Jobs, $jobs) or die(mysql_error());
$row_Hot_Jobs = mysql_fetch_assoc($Hot_Jobs);

if (isset($_GET['totalRows_Hot_Jobs'])) {
  $totalRows_Hot_Jobs = $_GET['totalRows_Hot_Jobs'];
} else {
  $all_Hot_Jobs = mysql_query($query_Hot_Jobs);
  $totalRows_Hot_Jobs = mysql_num_rows($all_Hot_Jobs);
}
$totalPages_Hot_Jobs = ceil($totalRows_Hot_Jobs/$maxRows_Hot_Jobs)-1;

$colname_joblink = "-1";
if (isset($_GET['job_id'])) {
  $colname_joblink = $_GET['job_id'];
}
mysql_select_db($database_jobs, $jobs);
$query_joblink = sprintf("SELECT * FROM jobs WHERE job_id = %s", GetSQLValueString($colname_joblink, "int"));
$joblink = mysql_query($query_joblink, $jobs) or die(mysql_error());
$row_joblink = mysql_fetch_assoc($joblink);
$totalRows_joblink = mysql_num_rows($joblink);

$colname_hot_jobs = "-1";
if (isset($_GET['1'])) {
  $colname_hot_jobs = $_GET['1'];
}
mysql_select_db($database_jobs, $jobs);
$query_hot_jobs = sprintf("SELECT * FROM jobs WHERE hot_job = %s ORDER BY created ASC", GetSQLValueString($colname_hot_jobs, "int"));
$hot_jobs = mysql_query($query_hot_jobs, $jobs) or die(mysql_error());
$row_hot_jobs = mysql_fetch_assoc($hot_jobs);
?>
<?php
//start session
session_start();

// Include all the output functions
require_once('fns.php'); 

// populate input fields into the session using a sub-array
// check http://www.scriptygoddess.com/archives/2007/05/28/how-to-use-session-cookies-in-php/
// also check the above link for remembering checkboxes values
$_SESSION['myForm'] = $_POST;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Monarch Recruitment - Creative &brvbar; Media &brvbar; Marketing Recruitment</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link rel="stylesheet" type="text/css" href="CSS/default.css" />
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="src/jquery.infieldlabel.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript" charset="utf-8">
		$(function(){ $("label").inFieldLabels(); });
	</script>
	<!--[if lte IE 6]>
		<style type="text/css" media="screen">
			form label {
					background: #fff;
			}
		</style>
	<![endif]-->
<script>
$(document).ready(function() {

	//rotation speed and timer
	var speed = 4000;
	var run = setInterval('rotate()', speed);	
	
	//grab the width and calculate left value
	var item_width = $('#slides li').outerWidth(); 
	var left_value = item_width * (-1); 
        
    //move the last item before first item, just in case user click prev button
	$('#slides li:first').before($('#slides li:last'));
	
	//set the default item to the correct position 
	$('#slides ul').css({'left' : left_value});

    //if user clicked on prev button
	$('#prev').click(function() {

		//get the right position            
		var left_indent = parseInt($('#slides ul').css('left')) + item_width;

		//slide the item            
		$('#slides ul:not(:animated)').animate({'left' : left_indent}, 200,function(){    

            //move the last item and put it as first item            	
			$('#slides li:first').before($('#slides li:last'));           

			//set the default item to correct position
			$('#slides ul').css({'left' : left_value});
		
		});

		//cancel the link behavior            
		return false;
            
	});

 
    //if user clicked on next button
	$('#next').click(function() {
		
		//get the right position
		var left_indent = parseInt($('#slides ul').css('left')) - item_width;
		
		//slide the item
		$('#slides ul:not(:animated)').animate({'left' : left_indent}, 200, function () {
            
            //move the first item and put it as last item
			$('#slides li:last').after($('#slides li:first'));                 	
			
			//set the default item to correct position
			$('#slides ul').css({'left' : left_value});
		
		});
		         
		//cancel the link behavior
		return false;
		
	});        
	
	//if mouse hover, pause the auto rotation, otherwise rotate it
	$('#slides').hover(
		
		function() {
			clearInterval(run);
		}, 
		function() {
			run = setInterval('rotate()', speed);	
		}
	); 
        
});

//a simple function to click next link
//a timer will call this function, and the rotation will begin :)  
function rotate() {
	$('#next').click();
}  
</script>
        <script type="text/javascript">
            $(document).ready(function(){

                $("#contactLink").click(function(){
                    if ($("#applyForm").is(":hidden")){
                        $("#applyForm").slideDown("slow"); 
                    }
                    else{
                        $("#applyForm").slideUp("slow");
                    }
                });
                
            });
            
            function closeForm(){
                $("#messageSent").show("slow");
                setTimeout('$("#messageSent").hide();$("#applyForm").slideUp("slow")', 4000);
           }
        </script>
</head>
<body><div id="outer">
<div id="pagetop"></div>
<div id="content">
<div id="main">
      <?php $_GET['job_id']; ?>
      <input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $row_joblink['posted_by']; ?>" /></p>
    <?php echo $row_joblink['job_title']; ?>
    </p>
    <p class="jobsalary"><?php echo $row_joblink['salary']; ?></p>
    <p class="joblocation"><strong><?php echo $row_joblink['location']; ?></strong></p>
    <p class="jobdescription"><?php echo nl2br($row_joblink['job_description']) ?></p>
  <div id="applyFormContainer">
<div id="applyForm">
<?php
	// contact form
	if (isset($_POST['submitted']) && ('true' == $_POST['submitted'])) { 
		// checks if the form is submitted and then processes it
    	process_form(); 
		
	} else { 
		// else prints the form
    	print_form(); 
	}
?>

Is this only one file or combined of 2 files....
* Are you getting the value for $theType, if not you need to put a default statement in your switch case
* There is no form tag in the page to submit the data
* The script is verymuch confusing, better to put functions in one page and split the code to have clear understand, even it makes better for you to debug easily

Hi Sai

Thanks for the quick response.

The code for the page with the include is below - please let me know if you need further info:

<?php if (isset($_GET['posted_by'])) 
	$adv = $_GET['posted_by'];?>
<?php require_once('Connections/jobs.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$maxRows_Hot_Jobs = 5;
$pageNum_Hot_Jobs = 0;
if (isset($_GET['pageNum_Hot_Jobs'])) {
  $pageNum_Hot_Jobs = $_GET['pageNum_Hot_Jobs'];
}
$startRow_Hot_Jobs = $pageNum_Hot_Jobs * $maxRows_Hot_Jobs;

mysql_select_db($database_jobs, $jobs);
$query_Hot_Jobs = "SELECT * FROM jobs WHERE hot_job = 1 ORDER BY created DESC";
$query_limit_Hot_Jobs = sprintf("%s LIMIT %d, %d", $query_Hot_Jobs, $startRow_Hot_Jobs, $maxRows_Hot_Jobs);
$Hot_Jobs = mysql_query($query_limit_Hot_Jobs, $jobs) or die(mysql_error());
$row_Hot_Jobs = mysql_fetch_assoc($Hot_Jobs);

if (isset($_GET['totalRows_Hot_Jobs'])) {
  $totalRows_Hot_Jobs = $_GET['totalRows_Hot_Jobs'];
} else {
  $all_Hot_Jobs = mysql_query($query_Hot_Jobs);
  $totalRows_Hot_Jobs = mysql_num_rows($all_Hot_Jobs);
}
$totalPages_Hot_Jobs = ceil($totalRows_Hot_Jobs/$maxRows_Hot_Jobs)-1;

$colname_joblink = "-1";
if (isset($_GET['job_id'])) {
  $colname_joblink = $_GET['job_id'];
}
mysql_select_db($database_jobs, $jobs);
$query_joblink = sprintf("SELECT * FROM jobs WHERE job_id = %s", GetSQLValueString($colname_joblink, "int"));
$joblink = mysql_query($query_joblink, $jobs) or die(mysql_error());
$row_joblink = mysql_fetch_assoc($joblink);
$totalRows_joblink = mysql_num_rows($joblink);

$colname_hot_jobs = "-1";
if (isset($_GET['1'])) {
  $colname_hot_jobs = $_GET['1'];
}
mysql_select_db($database_jobs, $jobs);
$query_hot_jobs = sprintf("SELECT * FROM jobs WHERE hot_job = %s ORDER BY created ASC", GetSQLValueString($colname_hot_jobs, "int"));
$hot_jobs = mysql_query($query_hot_jobs, $jobs) or die(mysql_error());
$row_hot_jobs = mysql_fetch_assoc($hot_jobs);
?>
<?php
//start session
session_start();

// Include all the output functions
require_once('fns.php'); 

// populate input fields into the session using a sub-array
// check http://www.scriptygoddess.com/archives/2007/05/28/how-to-use-session-cookies-in-php/
// also check the above link for remembering checkboxes values
$_SESSION['myForm'] = $_POST;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>Monarch Recruitment - Creative &brvbar; Media &brvbar; Marketing Recruitment</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link rel="stylesheet" type="text/css" href="CSS/default.css" />
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="src/jquery.infieldlabel.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript" charset="utf-8">
		$(function(){ $("label").inFieldLabels(); });
	</script>
	<!--[if lte IE 6]>
		<style type="text/css" media="screen">
			form label {
					background: #fff;
			}
		</style>
	<![endif]-->
<script>
$(document).ready(function() {

	//rotation speed and timer
	var speed = 4000;
	var run = setInterval('rotate()', speed);	
	
	//grab the width and calculate left value
	var item_width = $('#slides li').outerWidth(); 
	var left_value = item_width * (-1); 
        
    //move the last item before first item, just in case user click prev button
	$('#slides li:first').before($('#slides li:last'));
	
	//set the default item to the correct position 
	$('#slides ul').css({'left' : left_value});

    //if user clicked on prev button
	$('#prev').click(function() {

		//get the right position            
		var left_indent = parseInt($('#slides ul').css('left')) + item_width;

		//slide the item            
		$('#slides ul:not(:animated)').animate({'left' : left_indent}, 200,function(){    

            //move the last item and put it as first item            	
			$('#slides li:first').before($('#slides li:last'));           

			//set the default item to correct position
			$('#slides ul').css({'left' : left_value});
		
		});

		//cancel the link behavior            
		return false;
            
	});

 
    //if user clicked on next button
	$('#next').click(function() {
		
		//get the right position
		var left_indent = parseInt($('#slides ul').css('left')) - item_width;
		
		//slide the item
		$('#slides ul:not(:animated)').animate({'left' : left_indent}, 200, function () {
            
            //move the first item and put it as last item
			$('#slides li:last').after($('#slides li:first'));                 	
			
			//set the default item to correct position
			$('#slides ul').css({'left' : left_value});
		
		});
		         
		//cancel the link behavior
		return false;
		
	});        
	
	//if mouse hover, pause the auto rotation, otherwise rotate it
	$('#slides').hover(
		
		function() {
			clearInterval(run);
		}, 
		function() {
			run = setInterval('rotate()', speed);	
		}
	); 
        
});

//a simple function to click next link
//a timer will call this function, and the rotation will begin :)  
function rotate() {
	$('#next').click();
}  
</script>
        <script type="text/javascript">
            $(document).ready(function(){

                $("#contactLink").click(function(){
                    if ($("#applyForm").is(":hidden")){
                        $("#applyForm").slideDown("slow"); 
                    }
                    else{
                        $("#applyForm").slideUp("slow");
                    }
                });
                
            });
            
            function closeForm(){
                $("#messageSent").show("slow");
                setTimeout('$("#messageSent").hide();$("#applyForm").slideUp("slow")', 4000);
           }
        </script>
</head>
<body><div id="outer">
<div id="pagetop"></div>
<div id="content">
<div id="main">
      <?php $_GET['job_id']; ?>
      <input name="hiddenField" type="hidden" id="hiddenField" value="<?php echo $row_joblink['posted_by']; ?>" /></p>
    <?php echo $row_joblink['job_title']; ?>
    </p>
    <p class="jobsalary"><?php echo $row_joblink['salary']; ?></p>
    <p class="joblocation"><strong><?php echo $row_joblink['location']; ?></strong></p>
    <p class="jobdescription"><?php echo nl2br($row_joblink['job_description']) ?></p>
  <div id="applyFormContainer">
<div id="applyForm">
<?php
	// contact form
	if (isset($_POST['submitted']) && ('true' == $_POST['submitted'])) { 
		// checks if the form is submitted and then processes it
    	process_form(); 
		
	} else { 
		// else prints the form
    	print_form(); 
	}
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.