Jump to content

[SOLVED] form help.


Birdmansplace

Recommended Posts

Again remember to change 'tablename' to your actual table name for:

 

$query="SELECT * FROM tablename ORDER BY date DESC";

 

 

Secondly you'll need to add a basic url link at the end of form.php to allow the user to continue to view their own submission and those of others.

 

 

Finally I noticed a little glitch with form.php:

 

Find these lines:

 

     if 
        ($username && $amount)
        {  

 

and replace them with:

 

     if 
        ($username && $amount &&amountnumericcheck)
        {  

 

And finally replace these lines:

 

Amount:<input type="text" name="amount" id="amount" value="<?php if (isset($_POST['amount'])) echo $_POST['amount']; ?>"/>
<?php if ($message_amount) echo ''.$message_amount.''; ?>

 

with:

 

Amount:<input type="text" name="amount" id="amount" value="<?php if (isset($_POST['amount'])) echo $_POST['amount']; ?>"/>
<?php if ($message_amount) echo ''.$message_amount.''; ?>
<?php if ($message_amountnumericcheck) echo ''.$message_amountnumericcheck.''; ?>

 

This prevents the user from entering anything other than a number.

 

 

 

 

 

Link to comment
Share on other sites

  • Replies 68
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

well that will work im sure but clean up the font face stuff with some easy css on it would be alot better code

 

Definatley, the resulting form is ugly and css would defo streamline it more neatly. I'll leave the artistic liberty to his own discretion  for now though ;)

Link to comment
Share on other sites

assuming his code formats the text the way you want id use this just change tablename

 

 

<html>
<head>
<title>Donations</title>
</head>
<body>
<table border="1" cellspacing="2" cellpadding="2">
<tr>
<th>URN</th>
<th>User Name</th>
<th>Amount</th>
<th>IP Address</th>
<th>Date</th>
</tr>

<?php
// includes
include("dbinfo.php");


// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

// select database
mysql_select_db($db) or die ("Unable to select database!");

// generate and execute query
   
               $query = "SELECT * FROM TABLENAME ORDER BY date DESC";
                     
      $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
   
// if records present
if (mysql_num_rows($result) > 0)
{
// iterate through resultset
// print article titles
while($row = mysql_fetch_object($result))
{
?>  
<tr>
<td><?php echo $row->$urn; ?></td>
<td><?php echo $row->$username; ?></td>
<td><?php echo $row->$amount; ?></td>
<td><?php echo $row->$ipaddress; ?></td>
<td><?php echo $row->$date; ?></td>

</tr>

<?php
}
}
// if no records present
// display message
else
{
?>

<?php
}

// close database connection
mysql_close($connection);
?>

</table>
</body>
</html>

Link to comment
Share on other sites

assuming his code formats the text the way you want id use this just change tablename

 

Yep, that looks a lot more conventional and standardized.

 

What does -> do? I've seen it being used a few times.

 

Looks like Birdie got it working: http://birdmansplace.myftp.org/test/output.php

 

The date in your table only shows the date. Make sure your date column was set as datetime and not just date. Thats why the output order isn't ordered as it should be.

Link to comment
Share on other sites

drop: i did the table name change and i get this

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\test\output1.php on line 21

 

 

also i would like the date to sort by news date on top oldest on bottum.  i think that what i read, well understood form your code drop. 

 

Also your code drop is at http://birdmansplace.myftp.org/test/output1.php

Link to comment
Share on other sites

my bad  change your dbinfo.php  file to this

I didnt look at the file and used slightly different names for the fields

<?

// database configuration
$host = "localhost"; //hostname
$user = "USERNAME";  //username
$pass = "PASSWORD";   password
$db = "database name";  //database

?> 

Link to comment
Share on other sites

I'm always pedantic when it comes to databases. Just create your new table from scratch using the first bit of SQL code I gave you rather than changing the name of the current table. The only thing that needs changing is the destined database and the desired table name.

 

I think your date column is set as date rather than datetime. It needs the time as well to order correctly.

 

Check mine here:

 

http://www.joycepromotions.com/output.php

Link to comment
Share on other sites

Alright guys.  Thanks alot.  saved me hours and hours of personal head beatings.  I will leave the test folder and this info here for others to see.  And i will export the .sql file.

 

check it out:

form:http://birdmansplace.myftp.org/test/form.php                            output:http://birdmansplace.myftp.org/test/output.php

 

Download: http://birdmansplace.myftp.org/test/form.zip

Link to comment
Share on other sites

Good man!

 

Three final things:

 

1) Your link to output.php should not be at the end of your form. It should only show after submit where it says 'Thank you username'

 

After this line in form.php:

 

echo "Thank you $username !";

 

paste

 

echo "<a href='www.yoursite.com'>somelink</a>";

 

Do not use double quotations in the <a> tag.

 

2) At a later stage try editing the code I suggested earlier. As it stands users are allowed to enter non-numeric values into your amount text box.

 

 

3) When your happy with everything don't forget to close this thread (mark as solved at bottom of page).

 

Glad to help, later!  ;D

 

Link to comment
Share on other sites

np ive been thru the days of head beatings on lawrenceguide.org like hundreds of them i didnt know php at all before that project and ended up with a user driven site with all dynamic content and ratings scripts over like 2 months or so

 

Mmm, I'm going to try Allisons Supreme Chocolate Chip Cookies recipe.  :-*

 

 

Link to comment
Share on other sites

Alright guys.  Thanks alot.  saved me hours and hours of personal head beatings.  I will leave the test folder and this info here for others to see.  And i will export the .sql file.

 

check it out:

form:http://birdmansplace.myftp.org/test/form.php                            output:http://birdmansplace.myftp.org/test/output.php

 

Download: http://birdmansplace.myftp.org/test/form.zip

 

Everything is current. Injoy

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.