Jump to content

Help Please! HTML PHP Form Processing


jeffcfx

Recommended Posts

Alrighty. I'm pretty new to PHP, but this is the way to get better I guess I'll get right to it.

 

I am building a sort of verification mechanism. I want to have a user simply put in a mailfile code and have that mail file code used in a SELECT statement to query my sql database. I then want one of two things to happen. If the query returns a value, I want it to return specific columns from the database relating to that mailfile.

 

If nothing is found, I simply want it to return a static statement (MailFile Not Found)

 

I started with this which sort of works, but it returns the static statement from the very begining. I need it to return the static statement only after the user :

1: hits the submit button

and

2: the sql statement returns no rows

 

I think I need an if statement that requires 2 arguments to be true:

 

<form method="post" action="">

<p>Mail File: <input type="text" name="mailerName" id="mname" /></p>

<p><input type="submit" id="submit" name="submit" value="Send your Input" /></p>

 

 

</form>

 

<?php

 

$con = mysql_connect("abc.hostedresource.com","database","password");

$mf = $_POST['mailerName'];

 

if (!$con)

  {

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

  }

 

mysql_select_db("database");

 

$placeHolder=$_POST['mailerName'];

$sql = 'SELECT * FROM mailVerif WHERE fileName ="'.$placeHolder.'"';

$result = mysql_query($sql) or die(mysql_error());

 

  echo "<table border='0'>

<tr>

</tr>";

 

while($row = mysql_fetch_array($result))

  {

  echo "<tr>";

  echo "<td>" . $row['fileName'] . "</td>";

  echo "<td>" . $row['tollNum'] . "</td>";

  echo "<td>" . $row['time_stamp'] . "</td>";

  echo "</tr>";

  }

 

  echo "</table>";

 

if($result[0] == 0,) {

    echo "Appending to Database";

}

 

?>

 

Any help would be much apprceiated.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/181314-help-please-html-php-form-processing/
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.