Jump to content

Passing data back from PHP to HTML form


JIMBOJAMBO99

Recommended Posts

I have the following PHP script:

<?php

$link = mysql_connect('localhost', 'myuser', 'mypw')

    or die('Could not connect: ' . mysql_error());

#echo 'Connected successfully';

mysql_select_db('mydb') or die('Could not select database');

 

$fields = array();

$promo = $_POST['Promcode'];

 

#echo $fields;

 

if (isset($_POST["submit"])){

 

// Performing SQL query

$query = "SELECT * FROM promo WHERE (pcode = '$promo')" ;

# echo $query;

$result = mysql_query($query) or die('Query failed: ' . mysql_error());

 

#echo $result;

 

// Printing results in HTML

while($row = mysql_fetch_assoc($result)) {$_POST['Result'] = $row['pfraction'];}

$data= $_POST['Result'];

#echo $_POST['Result'];

// Free resultset

mysql_free_result($result);

 

// Closing connection

mysql_close($link);

 

}

 

?>

 

I've got a form and successfully picked up the promotion code discount fraction 'pfraction'.  How do I get this back into the source html form field 'Result'?  I'm new to PHP so please bear this in mind.  Any help appreciated.

 

Link to comment
https://forums.phpfreaks.com/topic/100910-passing-data-back-from-php-to-html-form/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.