Jump to content

Need help with PHP MYSQL


atrocious

Recommended Posts

Hi everyone,

 

                I am new to php and my sql. I want to do something for my website with php and mysql. here is what I want to do.

 

a) The user fills the forum (application) with all his details etc and when he/she click the submit button all the information gets stored in the database.

 

b) there is an admin page where admin can login can have universal or a unique password to check the recent application , Additionally he/she can will add necessary comments and which would be saved to the particular application.

 

c) now the user who applied can come back to a separate page and check his application status by his name.

 

d) if the admin approves the application he should be able to delete and modify and or edit the application.

 

I am able to make all the html pages my issue is with php code and mysql integration..can i please give me an  example if available or a code for php and mysql integration..it will be very helpful.

 

 

thanks

atrocious

Link to comment
https://forums.phpfreaks.com/topic/146889-need-help-with-php-mysql/
Share on other sites

First you need a page to connect to your database where you will include in your page

 

so make a file called config.php or something

 

and put this in it (change with your info)

 

<?php

 

$l = mysql_connect ( "host" , "username" , "pass" ) or die("Error connecting: <br><br>".mysql_error());

mysql_select_db( "database" ) or die("Error getting db: <br><br>".mysql_error());

 

?>

 

Then you can get started with you php

 

start with

 

<?

include 'config.php';

if(isset($_POST['submit']))

 

{

 

then you need to assign your fields as variables using this

 

$name = mysql_escape_string($_POST['name']);

 

for each field you want

 

then you do your query to enter it in your database

 

$sql = "INSERT INTO table(name, blah blah) VALUES ('{$name}', '{$blah blag}'')";

 

// Execute Query

 

$qry = mysql_query($sql) or die("MySQL Error: <br /> {$sql} <br />". mysql_error());

 

}

 

?>

 

Start with that :P

I have got the forums up and ready but my problem is the integration of php code into the forums. Below is the forum I have made please take a look.Like I understand that I have to create a table in Phpmyadmin but how do i use the code to insert it in to the database? I've been watching youtube tutorial etc but they are not specific enough and only show adding two values to two tables.

 

a) user application  http://www.atrocious.comuf.com/apply.html

 

b) user check status  http://www.atrocious.comuf.com/status.html

note: when user checks status he/she will only see hi/her name (ign) and the comment left by the admin.

 

c) admin page to add comment http://www.atrocious.comuf.com/admlogin.html

 

 

Please help me out. I will be very much thankful.

 

Regards,

Atrocious

Please help!!!!!  please help!!!!!  please help!!!

 

 

Here is what i've done so far. as you have already seen my application forum above if not here it is again www.atrocious.comuf.com/apply.html

 

I used the below php code to connect and then  insert the data  into the database.

 

Also note that i made a new database called "databasename" by mysql and i went into phpmyadmin and created a new table called "application" and i made 12 fields there to insert all these information. Now i uploaded these files to my server, went into the application page filled the forum up.

 

When i hit the submit button i get an error saying, "Error: Unknown column 'Rank' in 'field list'

Any solutions to this?

note that in my forums the text box field have the same name as in the post filed below....

 

 

 

 

<?php

 

$con = mysql_connect ( "myhost" , "databasename" , "pass" ) or die("Error connecting: <br><br>".mysql_error());

mysql_select_db( "databasename" ) or die("Error getting db: <br><br>".mysql_error());

 

 

 

$sql="INSERT INTO application (IGN, Rank, Age, Kdr, Whyjoin, Preclan, Hack, Email, Mapmode, Reco, Refer, Agree)

VALUES

('$_POST[id]','$_POST[Rank]','$_POST[Age]','$_POST[Kdr]','$_POST[Whyjoin]','$_POST[Preclan]','$_POST[Hack]','$_POST','$_POST[Mapmode]','$_POST[Reco]','$_POST[Refer]','$_POST[Agree]')";

 

if (!mysql_query($sql,$con))

  {

  die('Error: ' . mysql_error());

  }

echo " Thank you.";

 

mysql_close($con)

?>

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.