dalecosp;10974605 wrote:I'd recommend either
<html>
<head>
<title>My page</title>
or else:
<?php
/*
This is "my_script.php", written by me. It will either
display an error message or an HTML form, depending
on whether some value is set in the database.
*/
I dont wish to be so rude but i carnt help it. What you just replyed with is a little bit on the sarcastic side of replys. Im sorry to say im looking for help not insults. I have got that far, and further since posting this. However like i said im new to php and learn from being shown how to do it. And rung (like now) into issues fromm time to time and turn to forums full of experienced php coders for help!.
Since posting this i have managed to compile a PHP coded file. But have drawn a blank, it isnt working and am looking for advise as to why it wouldnt be working. When i say its not working it is displaying the form regardless of wether 'value' is empty or not. What it should be doing is if 'value' has content in it do NOT show the form and if the content of 'value' is empty show the form.
Please see the below code:
<?php
$con = mysql_connect(localhost,username,password); // the connection to ur database
$db = mysql_select_db(mydatabasename); // select the database name
$rs = mysql_query("select * from mytablename"); // the sql query to fetch records from ur table
if(mysql_num_rows($rs)>0)
{
if($row['value']=='')
{ ?>
<form name="frmEmail" method="post">
<table width="400" border="0">
<tr><td>Username:</td><td><input name="user" size="20" type="text" /></td></tr>
<tr><td>Password:</td><td><input name="pass" size="20" type="password" /></td></tr>
<tr><td>Verify Password:</td><td><input name="vpass" size="20" type="password" /></td></tr>
<tr><td colspan="2" align="center"><hr /><input name="submit" type="submit" value="Create Email" /></td></tr>
</table>
</form>
<?php } else
{ ?>
<div class="error">Sorry, you already have data created on <?= $row['created_at']; ?>.
<?php }
}
else
echo 'Failed to retrieve records';
?>
I maybe missing something really silly and just to help you out a little more i have provided an image of the table in question inside the mysql database. Please see the attached image link just below this text.