Jump to content

php html link pass through


dcowen

Recommended Posts

I have researched and still have not been successfully able to pass my variable to my url.  When I click the link, the url takes me to the appropriate page but the variable is blank.  Any help is appreciated.  Thank you.

 

<?php

  require_once('connvars.php');

 

$dbc=mysqli_connect(db_host,db_user,db_password,db_name)or die('Error connecting to MySQL server.');

 

  $search_criteria=$_POST['searchcriteria'];

  $job_id=$_GET['job_id'];

  echo $job_id;

 

 

  $query="Select * from job where tc_number='$search_criteria'";

  $result=mysqli_query($dbc,$query);

  while ($row=mysqli_fetch_array($result)){

    echo $row['job_id'];

    echo ' '.$row['tc_number'];

    echo ' '.$row['prop_addr_1'];

    echo '<br/>';}

    echo '<a href="propinsp.php?job_id='. $job_id .'">click here</a>';

                     

  mysqli_close($dbc);

Link to comment
Share on other sites

Here is all of it.  Lukeidiot I did try your response, the variable is still blank.

 

</head>

<body>

<p><img src="transconlogo12-12_jkqn" alt="Transcontinental Valuations logo." height="80" width="396" /></p>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">

<?php

  require_once('connvars.php');

 

$dbc=mysqli_connect(db_host,db_user,db_password,db_name)or die('Error connecting to MySQL server.');

 

  $search_criteria=$_POST['searchcriteria'];

  $query="Select * from job where tc_number='$search_criteria'";

  $result=mysqli_query($dbc,$query);

  while ($row=mysqli_fetch_array($result)){

    echo $row['job_id'];

    echo ' '.$row['tc_number'];

    echo ' '.$row['prop_addr_1'];

    echo '<br/>';}

    echo "<a href='propinsp.php?job_id=$job_id'>click here</a>";               

  mysqli_close($dbc);

 

?>

<h4><span>Locate a Property Inspection:</span></h4>

<input class="searchtext" id="searchcriteria" name="searchcriteria" value="Enter TC Number" /><input class="headerSubmit" id="go" name="go" value="Go" type="submit" />

 

 

<ul id="headerNav">

<li><a href="upload.php" title="upload">Upload</a></li>

<li><a href="pending.php" title="Pending">Pending</a></li>

<li class="headerRight"><a href="/logout" title="Logout">Logout</a></li>

</ul>

</form>

</body>

</html>

Link to comment
Share on other sites

A little background of what I am trying to accomplish.

 

I am asking the user to enter an id that is "supposed" to be unique from a different system (tc_number).  Historically, I have found that system's uniqueness to be questionable.  That being said, I have a truly unique identifier in my database job_id.  the database is queried from the tc_number and pulls the job_id.

Link to comment
Share on other sites

I mean blank as in the URL shows the following.  http://www.tcvpath.com/propinsp.php?job_id=

 

I added the or die you suggested.  I did not receive the error, but I didn't expect one because I have results of the query echo on the page when I click the submit button.  I appreciate your help with this, I have been pulling my hair out for a week.

Link to comment
Share on other sites

In your last code you posted you still have

echo "<a href='propinsp.php?job_id=$job_id'>click here</a>";

instead of

echo '<a href="propinsp.php?job_id='. $row['job_id'] .'">click here</a>';

 

I am also assuming that propinsp.php is another page that you haven't posted

Link to comment
Share on other sites

Yeah, LukeIdiot had me change the code to that.  I have changed it back to your suggestion and the propinsp.php is below.  Again, thank you for your time.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <title>Property Inspection Form</title>

  <link rel="stylesheet" type="text/css" href="style.css" />

</head>

<body>

<p><img src="transconlogo12-12_jkqn" alt="Transcontinental Valuations logo." height="80" width="396" /></p>

<h4><center><U>PROPERTY INSPECTION FORM</center></U></h4>

<form method="post" action="<?php echo$_SERVER['PHP_SELF'];?>">

 

<?php

 

require_once('connvars.php');

 

if (isset($_GET['job_id'])){

  $job_id=$_GET['job_id'];}

else if (isset($_POST['job_id'])){

  $job_id=$_POST['job_id'];}

else echo'<p class="error">No TC Number Selected.</p>';

 

$dbc=mysqli_connect(db_host,db_user,db_password,db_name);

$query="select * from prop_insp";

$result=mysqli_query($dbc,$query);

 

 

echo $_GET[job_id];

  mysqli_close($dbc);

echo '<p>Job ID:  '. $job_id. '</p>';

?>

 

 

<h4><B>Instructions to Broker/Agent</b></h4>

<ul>

<li>Please inspect and complete within 1 business day, unless otherwise agreed upon

<li>Be sure to answer all quetions on the form.  Single click on the Yes and No boxes to insert a checkmark

<li>Make comments when necessary

<li>To insert photos, double click on the photo icon.  Label each photo to the right of the image

<li>Be sure to include a photo of the Winterization Notification, if applicable to the subject

</ul>

 

<label for="prop_addr_1">Property Address:</label> <br />

<label for="prop_addr_2">Property Address 2:</label>

<label for="prop_city">City:</label> <input id="prop_city" name="prop_cityy" type="text"/><br />

<label for="prop_state">State:</label> <input id="prop_state" name="prop_state" type="text"/><br />

<label for="prop_zip">Zip:</label> <input id="prop_state" name="prop_state" type="text"/><br />

<label for="prop_county">County:</label> <input id="prop_county" name="prop_county" type="text"/><br />

<label for="listing_agent">Listing Agent:</label> <input id="listing_agent" name="listing_agent type="text"/><br />

<label for="listing_office">Listing Office:</label> <input id="listing_office" name="listing_office" type="text"/><br />

<label for="listed_mls">Is the property currently listed on MLS?</label> Yes <input id="listed_mls" name="listed_mls" value="yes" type="radio" /> No <input id="listed_mls" name="listed_mls" value="no" type="radio" /><br />

<label for="mls_number">MLS Number:</label> <input id="mls_number" name="mls_number" type="text"/><br />

<label for="listed_realtor">Is the property currently listed on Realtor.com?</label> Yes <input id="listed_realtor" name="listed_realtor" value="yes" type="radio" /> No <input id="listed_realtor" name="listed_realtor" value="no" type="radio" /><br />

<label for="curr_price">Current Price:</label> <input id="curr_price" name="curr_price type="currency"/><br />

<label for="prev_price">Previous List Price:</label> <input id="prev_price" name="prev_price" type="text"/><br />

<label for="dt_last_reduc">Date of Last Price Reduction:</label> <input id="dt_last_reduc" name="dt_last_reduc" type="date"/><br />

<label for="sale_sign">Is there a for sale sign visible fromt he street?</label> Yes <input id="sale_sign" name="sale_sign" value="yes" type="radio" /> No <input id="sale_sign" name="sale_sign" value="no" type="radio" /><br />

<label for="sale_sign_comm">Comment?</label> <textarea id="sale_sign_comm" name="sale_sign_comm"></textarea><br />

<label for="vandalism">Are there any signs of vadalism?</label> Yes <input id="vandalism" name="vandalism" value="yes" type="radio" /> No <input id="vandalism" name="vandalism" value="no" type="radio" /><br />

<label for="vandalism_comm">Comment?</label> <textarea id="vandalism_comm" name="vandalism_comm"></textarea><br />

<label for="code_viol">Are there any visible signs of code violations?</label> Yes <input id="code_viol" name="code_viol" value="yes" type="radio" /> No <input id="code_viol" name="code_viol" value="no" type="radio" /><br />

<label for="code_viol_comm">Comment?</label> <textarea id="code_viol_comm" name="code_viol_comm"></textarea><br />

<label for="health_safe">Are there any health and safety issues with the property?</label> Yes <input id="health_safe" name="health_safe" value="yes" type="radio" /> No <input id="health_safe" name="health_safe" value="no" type="radio" /><br />

<label for="health_safe_comm">Comment?</label> <textarea id="health_safe_comm" name="health_safe_comm"></textarea><br />

<label for="prop_secure">Is the property secured?</label> Yes <input id="prop_secure" name="prop_secure" value="yes" type="radio" /> No <input id="prop_secure" name="prop_secure" value="no" type="radio" /><br />

<label for="prop_secure_comm">Comment?</label> <textarea id="prop_secure_comm" name="prop_secure_comm"></textarea><br />

<label for="land_main">Is the landscaping maintained?</label> Yes <input id="land_main" name="land_main" value="yes" type="radio" /> No <input id="land_main" name="land_main" value="no" type="radio" /><br />

<label for="land_main_comm">Comment?</label> <textarea id="land_main_comm" name="land_main_comm"></textarea><br />

<label for="int_clean">Is the interior of the property clean?</label> Yes <input id="int_clean" name="int_clean" value="yes" type="radio" /> No <input id="int_clean" name="int_clean" value="no" type="radio" /><br />

<label for="int_clean_comm">Comment?</label> <textarea id="int_clean_comm" name="int_clean_comm"></textarea><br />

<label for="electricity">Is the electricity turned on?</label> Yes <input id="electricity" name="electricity" value="yes" type="radio" /> No <input id="electricity" name="electricity" value="no" type="radio" /><br />

<label for="electricity_comm">Comment?</label> <textarea id="electricity_comm" name="electricity_comm"></textarea><br />

<label for="water">Is the water turned on?</label> Yes <input id="water" name="water" value="yes" type="radio" /> No <input id="water" name="water" value="no" type="radio" /><br />

<label for="water_comm">Comment?</label> <textarea id="water_comm" name="water_comm"></textarea><br />

<label for="winterized">If between September and April, are there notices that the home has been winterized? (please provide photos of notices)?</label> Yes <input id="winterized" name="winterized" value="yes" type="radio" /> No <input id="winterized" name="winterizedr" value="no" type="radio" /><br />

<label for="winterized_comm">Comment?</label> <textarea id="winterized_comm" name="winterized_comm"></textarea><br />

 

<label for="add_comm">Please provide any additional comments, such as, condition of neighboring homes, current real estate market conditions in the area.</label> <textarea id="add_comm" name="add_comm"></textarea><br />

<label for="agent_name">Agent Name:</label> <textarea id="agent_name" name="agent_name"></textarea><br />

<label for="insp_comp_dt">Agent Name:</label> <textarea id="insp_comp_dt" name="insp_comp_dt"></textarea><br />

 

</form>

<input type="submit" value="Submit Data" name="submit" />

</body>

</html>

 

 

Link to comment
Share on other sites

Okay first off please use code tags (using

[/b]..code...[b]

or

[/b]..code...[b]

) when when you post your code.

 

if your trying to get the ID from the database record and pass that via the URL to the next page your need move the echo inside the loop

ie

<body>
<p><img src="transconlogo12-12_jkqn" alt="Transcontinental Valuations logo." height="80" width="396" /></p>
<form method="post" action="<?php echo $_SERVER ['PHP_SELF'];?>">
<?php
require_once ('connvars.php');

$dbc = mysqli_connect ( db_host, db_user, db_password, db_name ) or die ( 'Error connecting to MySQL server.' );

$search_criteria = $_POST ['searchcriteria'];
$query = "Select * FROM job WHERE tc_number='$search_criteria'";
$result = mysqli_query ( $dbc, $query );
while ( $row = mysqli_fetch_array ( $result ) ) {
echo $row ['job_id'];
echo ' ' . $row ['tc_number'];
echo ' ' . $row ['prop_addr_1'];
echo '<br/>';
echo "<a href='propinsp.php?job_id=".$row ['job_id']."'>click here</a>";
}
mysqli_close ( $dbc );

?>
<h4><span>Locate a Property Inspection:</span></h4>
<input class="searchtext" id="searchcriteria" name="searchcriteria"
value="Enter TC Number" /><input class="headerSubmit" id="go" name="go"
value="Go" type="submit" />


<ul id="headerNav">
<li><a href="upload.php" title="upload">Upload</a></li>
<li><a href="pending.php" title="Pending">Pending</a></li>
<li class="headerRight"><a href="/logout" title="Logout">Logout</a></li>
</ul>
</form>
</body>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.