Jump to content
MakeWebGames

Recommended Posts

Posted (edited)

i wanted a newspaer with ads on it so user can click the newspaper link and be able to add a title and message and post it for $5000 game cash and underneath it should view there post but i seem to have a problem it dont show the box or anything it shows a blank page can anyone correct this please.

am new coder and dont know 100% coding and this code is messy i know so can someone help me so i can learn from my mistake pls appreciate my efforts

 

<?php
include "globals.php";

if($_GET['action'] == "add")

{ 
print "


<h3>Add Advertisement ($5,000)</h3>

<table width='80%' border='0' cellspacing='1' class='table'><tr colspan='2'>
<th><b>Newspaper:</b></th>
</tr>
<td>

<form action='newspaper.php?action=added' method='post'>

<table width='100%'>

<tr><td valign=top >Title: </td>
<td valign=top >
<input type='text' name='npTITLE' class='textbox'> </td></tr>

<tr><td valign=top >Message: </td>
<td valign=top>
<textarea rows=8 cols=40 name='npBODY' class='textbox'></textarea>
</td></tr>
<tr>

<td valign=top> </td>
<td valign=top >
<input class='textbox' type='submit' value='Place Ad ($5000)' /> </td>
</table>
</form>
"; }

if($_GET['action'] == "added")
{
if($ir['money']>5000)
{ print "Congratulations, you bought a an ad for \$5,000!
";
$q=$db->query("SELECT * FROM newscontent LIMIT 1",$c);
$ncontent=mysql_result($q,0,0);
$q=$db->query("SELECT * FROM papercontent LIMIT 1",$c);
$content=mysql_result($q,0,0);
$q=$db->query("SELECT * FROM npaper LIMIT 10");
while($na=mysql_fetch_array($q))

$db->query("UPDATE users SET money=money-5000 WHERE userid=$userid");
$title=str_replace(array("\n"),array("
"),strip_tags($_POST['npTITLE']));
$body=str_replace(array("\n"),array("
"),strip_tags($_POST['npBODY']));
$q=$db->query("INSERT INTO `npaper` VALUES (NULL, '$userid', '$title', '$body', unix_timestamp())");
print "Ad Added!
<a href='http://newspaper.php' target='_blank'>>Back</a>";
} else {
print "You do not have enough money to add an ad.
"; } }

?>
Edited by gangsta life
Posted

Think I have helped you before your under a new name, anyways have you added the sqls to your database? Before I believe I helped you with a mod you had not added the sqls why you gotten the blank page...

Posted (edited)

Checked it...

 

<?php
include "globals.php";



if($_GET['action'] == 'add')
 { 
print "<br />
<h3>Add Advertisement ($5,000)</h3><br />
<table width='80%' border='0' cellspacing='1' class=''>
<tr colspan='2'>
  <th><b>Newspaper:</b></th></tr>
  <td>
  <form action='newspaper.php?action=added' method='post'>
<table width='100%'>
<tr>
 <td valign=top>Title: </td>
 <td valign=top>
 <input type='text' name='npTITLE' class='textbox'> </td></tr>
<tr>
 <td valign=top>Message: </td>
 <td valign=top>
 <textarea rows=8 cols=40 name='npBODY' class='textbox'></textarea>
 </td></tr>
<tr>
 <td valign=top> </td>
 <td valign=top >
 <input class='textbox' type='submit' value='Place Ad ($5000)' /> </td>
</table></form>"; 
 }


if($_GET['action'] == 'added')
   {
  if($ir['money']<5000)
       { 
       print "You do not have enough money to add an ad.<br />"; 
       exit;
       }

       print "Congratulations, you bought a an ad for \$5,000!";

$q=$db->query("SELECT * FROM newscontent LIMIT 1",$c);
$ncontent=mysql_result($q,0,0);
$q=$db->query("SELECT * FROM papercontent LIMIT 1",$c);
$content=mysql_result($q,0,0);
$q=$db->query("SELECT * FROM npaper LIMIT 10");
while($na=mysql_fetch_array($q))
   {
   $db->query("UPDATE users SET money=money-5000 WHERE userid=$userid");
   $title=str_replace(array("\n"),array("<br />"),strip_tags($_POST['npTITLE']));
   $body=str_replace(array("\n"),array("<br />"),strip_tags($_POST['npBODY']));
   $q=$db->query("INSERT INTO `npaper` VALUES (NULL, '$userid', '$title', '$body', unix_timestamp())");
   print "Ad Added!<br /><a href='http://newspaper.php' target='_blank'>>Back</a>";
   } 
   }

?>

 

Your link in your other page to go to this one needs to be newspaper.php?action=add

Your money should not be greater it should be less than 5k... changed that for you also.

Edited by lucky3809
Posted (edited)

You did not direct the link to the action like I said... where ever the link is you need to add...

newspaper.php?action=add

then it will appear... you can't just add newspaper.php that's not how you have your script.. You added actions so they need to be called...

If you dont want it that way you need to recode it and make a submit page separate from the form...

You currently have

if($_GET['action'] == 'add')

and

if($_GET['action'] == 'added')

which you need to add the action to your link...

such as I have typed prior...

Edited by lucky3809
Posted (edited)

OMG your kidding you don't know how to link it? You already have newspaper.php in your other page that you ware clicking...

just add ?action=add

in your browser put http://www.yourgame.com/newspaper.php?action=add

 

Think you should really learn php look on the net for some tuts... I dont have time to teach lol....

As for it directly showing it, it will directly go to the form if you add the ?action=add to your link...

Edited by lucky3809
Posted

okay i have tried it it did work but i dont want it like that i want it on all on one page so all funtions on one page newspaper.php so basically i dont want action saying then for it to display the table i want it to display then once added the funtion i want it action=added but i removed if($_GET['action'] == 'add')

{ it doesnt work shows error?

Posted

well i do want it like that but a little adjust can you help me basically i want some when you click on news paper it shows table with title, and message section then once added and paid for you ad should display on the same page below the tabel. i have fixed the table section but when i add a ad it say congrats then i still have my money and doesnt display nothing?

Posted

If it's not updating then your if else brackets aren't in the right position in your script...Or else your query is wrong and it's not updating... but imo if it's not displaying anything its your brackets placed wrong...

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.   Paste as plain text instead

  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...