Jump to content

Need to tweak the code! Please help now! php mysql, thanks in advance


atrocious

Recommended Posts

You are fabulous! If you are a girl i will e-kiss you! If you are a guy then thank you so much :D

 

I haven't tried the code yet but the way it looks i think is gonna work. I will implement that later. Now i have the last part to finish. This is admin login. I don't want to create the register part. I will add username and password by phpmyadmin creating a new table  and give it to the admins. Check the admin login page. http://atrocious.comuf.com/admlogin.html

 

Interesting part:

When they click submit their username and password will be verified and they will enter a new page where they will be able to see all existing application. Then they can select the particular application and add comments on it.

 

Now i understand how the admin login page and how to extract all the info from the application table (even though dont have the code for it :( but how do i add info to that particular application? or in other words how do i add more stuff to the existing table.

 

this is tough for me. Your help will be greatly appreciated. Thank you php freaks this is such a nice platform to learn.

 

 

<?php
$con = mysql_connect("host" , "database" , "pw");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("databasename", $con);

//when clicked on particular application link, IGN for that record will be passed by GET method to this page.
$applicationID = $_GET['ign'];

//Code here to show form and text box to adde comments... form should submit to this page itself...
// assumption form has a submit button called btnAddSubmit and textbox called txtComments, 
//add a field called admin_comments in table...
// also make sure u pass the ign to the form action URL example...form action should be
// thispage.php?ign=<?php echo $_GET['ign'] ?>

if(isset($_POST['btnAddSubmit']) && trim($_POST['txtComments']) != "") {
$result = mysql_query("UPDATE application SET `admin_comments` = '". mysql_real_escape_string($_POST['txtComments']) ."' WHERE `IGN` = '".$_GET['ign']."'");		
}


//to see particular application, 
$result = mysql_query("SELECT * FROM application WHERE `IGN` = '".$ign."'");

echo "<table border='1'>
<tr>
<th>In Game Name</th>
<th>Comments:</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['ign'] . "</td>";
  echo "<td>" . $row['comment'] . "</td>";
  echo "<td>" . $row['admin_comment'] . "</td>";
  echo "</tr>";
  }
echo "</table>";




mysql_close($con);
?>

 

 

something like this...

 

BTW i am a guy ;)

I am modifying the application for more simplicity. I worked on admin login creating a username and password in mysql and followed a tutorial in book and in youtube nothing worked so i decided to put this admin page in password protected directory so i don't have to do admin login now.

 

So once the admin gets on page he/she should be able to see all the application. It means all the applicants in the table should be listed and read. Now a comment box should be at the bottom of the page where the admin can put a particular IGN and add comments.

 

Samshel can i add an html code where you have commented to say write code here? And will it do the things that i have mentioned above? Once again thank you for your help. thankful to you and the phpfreaks community.

Yes.

 

From the page where u r showing all applications, there will be link for each application with ign of the application attached in query string...

your main page will look like...

<?php
$con = mysql_connect("host" , "database" , "pw");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("databasename", $con);

$ign = mysql_real_escape_string($_POST['ign']);

$result = mysql_query("SELECT * FROM application WHERE `IGN` = '".$ign."'");

echo "<table border='1'>
<tr>
<th>In Game Name</th>
<th>Comments:</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td><a href='viewapplication.php?ign='" . $row['ign'] . ">". $row['ign'] ."</a></td>";
  echo "<td>" . $row['comment'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>

 

 

in viewapplication.php write the code which i gave in last post...and put HTML form as mentioned in the comments.

 

<?php
$con = mysql_connect("host" , "database" , "pw");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("databasename", $con);

//when clicked on particular application link, IGN for that record will be passed by GET method to this page.
$applicationID = $_GET['ign'];

//Write HTML here to show form and text box to adde comments... form should submit to this page itself...
// assumption form has a submit button called btnAddSubmit and textbox called txtComments, 
//add a field called admin_comments in table...
// also make sure u pass the ign to the form action URL example...form action should be
// thispage.php?ign=<?php echo $_GET['ign'] ?>

if(isset($_POST['btnAddSubmit']) && trim($_POST['txtComments']) != "") {
$result = mysql_query("UPDATE application SET `admin_comments` = '". mysql_real_escape_string($_POST['txtComments']) ."' WHERE `IGN` = '".$_GET['ign']."'");		
}


//to see particular application, 
$result = mysql_query("SELECT * FROM application WHERE `IGN` = '".$ign."'");

echo "<table border='1'>
<tr>
<th>In Game Name</th>
<th>Comments:</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['ign'] . "</td>";
  echo "<td>" . $row['comment'] . "</td>";
  echo "<td>" . $row['admin_comment'] . "</td>";
  echo "</tr>";
  }
echo "</table>";




mysql_close($con);
?>


 

Ok here is what i have so far. I am able to read all the fields from the application table. I also have a forum in the bottom where admin can put IGN and comments when they hit submit.

Now my issue:

Once they hit submit how do i get the particular IGN from the database and be able to write on the comment section?

 

 <?php
$con = mysql_connect("host" , "database" , "pw");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("databasename", $con);

$result = mysql_query("SELECT * FROM application");

echo "<table border='1'>
<tr>
<th>In game name</th>
<th>Rank</th>
<th>Age</th>
<th>KD</th>
<th>Why join us?</th>
<th>Previous Clan</th>
<th>Hacking history</th>
<th>Email</th>
<th>Fav map/mode</th>
<th>How you heard about us?</th>
<th>Reference</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['ign'] . "</td>";
  echo "<td>" . $row['Rank'] . "</td>";
  echo "<td>" . $row['Age'] . "</td>";
  echo "<td>" . $row['Kdr'] . "</td>";
  echo "<td>" . $row['Whyjoin'] . "</td>";
  echo "<td>" . $row['Preclan'] . "</td>";
  echo "<td>" . $row['Hack'] . "</td>";
  echo "<td>" . $row['Email'] . "</td>";
  echo "<td>" . $row['Mapmode'] . "</td>";
  echo "<td>" . $row['Reco'] . "</td>";
  echo "<td>" . $row['Refer'] . "</td>";
  echo "<td>" . $row['Comment'] . "</td>";
  
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>
<html>
<head></head>
<title> </title>
<body>
<html>
<head></head>
<title> </title>
<body>
<form id="form1" name="form1" method="post" action="">
  <p>Enter IGN to add comments: 
    <input name="ign" type="text" id="ign" />
    </p>
  <p>Enter your comments here:</p>
  <p>
    <textarea name="comments" rows=4 cols=48 id="comments"></textarea>
  </p>
  <p>
    <input name="submit" type="submit" id="submit" value="Submit" />
    <input type="reset" name="Reset" value="Reset" />
  </p>
</form>


</body>
</html>

please see my above post, the form will be on second page, what u r working on is the first page. First page will have list of all applications with a hyperlink for each as shown in code block 1..

 

 

then in second page, you put the form...

Samshel so instead of having a link what i did was when the admin enters the page they will see list of all the applicant and at the bottom of the page they will find the text field to enter ign and comment and once they hit submit it should update the comment section for the particular ign.

So if they hit the submit button the below php code will be executed.

 

But i am not getting the code to work. Please modify it. Many many many thanks.

 

<?php
$con = mysql_connect("host" , "user" , "pw");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("databasename", $con);

mysql_query("update tableName set comment='$_POST[comments]', ... where primaryKey='$_POST[ign]'");

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.