/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Some help for a newbie.

Hey guys, I’m having a bit of trouble here. Im a total php newb, and all attempts to customize the following script have failed. Horribly. The script gives this [URL=http://thefunklounge.com/comicz/post.php]form[/URL]. See how there’s two sections. The top is for news posts and the bottom is for naming uploaded pictures. I only need the bottom part for naming comics, as I use something else for news posts. Now my dilemma. I looked at this big chunk-0-code, but I don’t know how to isolate the part that gives me the comic name post thingy from the rest of the code so I can delete everything else I don’t need. None of my friends know php and I couldn’t track down the original author, so here I am. I hope someone can help me.

[code=php]<?

// This is the first PHP work I’ve ever released publicly, so if
// you’ve got complaints or insults, please be gentle. ^_^
// As for some actual usage notes… I’ve made it so that you can
// enter anything into the post, and it’ll work. That includes
// double- and single-quotation marks. You can also have fun with
// back-slashes and all that other crap. You don’t need to insert
// HTML for <p>, because I’ve programmed the script to automatically
// turn any and all carriage returns into <p>’s for you. Have fun!
// Oh, and make sure you CHMOD your /news/ directory to allow for
// Public Writing. Don’t worry, the public won’t be writing to your
// news directory… this is just necessary for the post to work.
// ***********************************************

$myPassword = “chooseapassword”;
$myComicPassword = “chooseapassword”;
$myDirectory = “/your/news/directory/”;
$posterName[0] = “yourname”;
// $posterName[0] = “dude1”;
// $posterName[1] = “dude2”;
// $posterName[2] = “dude3”;
$colorBackground = “#FFCC99”;
$colorText = “#330066”;

// *************************** THE WORKS
// DO NOT TOUCH!!
if(isset($_POST[‘comicTitle’])){
$comicTitle = $_POST[‘comicTitle’];
}
if(isset($_POST[‘comicPassword’])){
$comicPassword = $_POST[‘comicPassword’];
}
if(isset($_POST[‘comicTitlePosted’])){
$comicTitlePosted = $_POST[‘comicTitlePosted’];
}

if(isset($_POST[‘postTitle’])){
$postTitle = $_POST[‘postTitle’];
}
if(isset($_POST[‘password’])){
$password = $_POST[‘password’];
}
if(isset($_POST[‘postText’])){
$postText = $_POST[‘postText’];
}
if(isset($_POST[‘posted’])){
$posted = $_POST[‘posted’];
}
if(isset($_POST[‘poster’])){
$poster = $_POST[‘poster’];
}

function printPostForm()
{
foreach (array_keys($GLOBALS) as $i) {if(!isset(${$i})) global ${$i};} // Gather globals.

if( (@$password == null) and (@$posted == null) ) // If this is the first visit,
print(“”); // Do nothing.
else if($password != $myPassword) // If the password variable is wrong,
print(“<center>Incorrect password, please try again.</center>”); // Display error message.
else if($password == $myPassword) // If the password variable is right…
{
if($poster == “unchosen”) // If the poster was not specified,
print(“<center>Please specify a poster.</center>”); // Display error message.
else if($postTitle == null) // If the title was left blank,
print(“<center>Please enter a title.</center>”); // Display error message.
else if($postText == null) // If the article was left blank,
print(“<center>Please enter an article.</center>”); // Display error message.
else // If everything is in order…
{
$date = date(“ymd-Hi-“); // Create the $date string.
$fileName = “$date$poster.php”; // Create the $fileName string.

$postTitle = str_replace(“\'”, “‘”, $postTitle); // Fix any apostrophe problems in the title.

$postText = str_replace(“\'”, “‘”, $postText); // Fix any apostrophe problems in the article.
$postText = str_replace(”
“, “n<p>n”, $postText); // Turn all carriage returns to <p>.
// $postText = str_replace($postFind, $postReplace, $postText); // postReplacements.php mod… saving this for later!

$file = fopen(“$myDirectory$fileName”, “w+”); // Create the file.

fputs($file, ‘<?php
$postTitle = “‘);
fputs($file, “$postTitle”);
fputs($file, ‘”;
$postText = ”

‘);
fputs($file, “$postText”);
fputs($file, ‘

“;
?>’);

fclose($file); // Close the file.
}
}

if( (@$password != $myPassword) or (@$poster == “unchosen”) or (@$postText == null) or ($postTitle == null) ) // If anything is wrong/blank…
{
@$postText = stripslashes($postText); // Remove all slashes from the article.
@$postTitle = stripslashes($postTitle); // Remove all slashes from the title.

print(“<form method=”post” action=””>
<table border=”0″ cellpadding=”10″ cellspacing=”0″>
<tr>
<td align=”left” width=”33%”>
<br><select language=”JavaScript” size=”1″ style=”background-color: $colorBackground; font-size: 10 pt; font-family:

tahoma; color: $colorText;” name=”poster”>
<option value=”unchosen”>Poster:n”);

for($i = 0; $i < sizeof($posterName); $i++) // Drop-down loop for the posters.
{
if(@$poster == $posterName[$i]) // Remember the poster if this page has been reloaded.
$selected = “selected”; // Reselect that poster.
else
$selected = “”;

print(” <option value=”$posterName[$i]” $selected>$posterName[$i]n”);
}

print(”
</select>
</td>
<td align=”center” width=”33%”>
<b>Title of post:</b><br>
<input type=”text” name=”postTitle” value=”$postTitle” style=”background-color: $colorBackground; font-size: 10 pt;

font-family: tahoma; color: $colorText;”></input>
</td>
<td align=”right” width=”33%”>
<b>Password:</b><br>
<input type=”password” name=”password” style=”background-color: $colorBackground; font-size: 10 pt; font-family:

tahoma; color: $colorText;”></input>
</td>
</tr>
<tr>
<td align=”center” colspan=”3″>
<textarea rows=”20″ cols=”75″ name=”postText” style=”background-color: $colorBackground; color:

$colorText;”>$postText</textarea><p>
<input type=”submit” name=”posted” value=”Post It” style=”background-color: $colorBackground; font-size: 10 pt;

font-family: tahoma; color: $colorText”></input>
</td>
</tr>
</table>
</form>”);
}
else if( ($password != null) and ($password == $myPassword) and ($poster != “unchosen”) and ($postText != null) and ($postTitle !=null) )
print(“<center>Article has been posted.</center>”);

// *****************************************************************

if( (@$comicPassword == null) and (@$comicTitlePosted == null) ) // If this is the first visit,
print(“<p><hr>”); // Do nothing.
else if($comicPassword != $myComicPassword) // If the password variable is wrong,
print(“<p><hr><p><center>Incorrect password, please try again.</center>”); // Display error message.
else if($comicPassword == $myComicPassword) // If the password variable is right…
{
$comicTitle = str_replace(“\'”, “‘”, $comicTitle); // Fix any apostrophe problems in the title.

include(“comicConfig.php”);
include($fileTitles);

$totalComicsNew = $totalComics + 1;

$file = fopen($fileTitles,”r+”);
fseek($file, 4);
fputs($file, “n” . ‘$totalComics = ‘. “$totalComicsNew;n”);
fseek($file, -3, SEEK_END);
fputs($file, ‘$titleStrip[‘ . “$totalComicsNew] = “$comicTitle”;nn?>”);

fclose($file); // Close the file.
}

if( (@$comicPassword != $myComicPassword) or ($comicTitle == null) ) // If anything is wrong/blank…
{
@$comicTitle = stripslashes($comicTitle); // Remove all slashes from the title.

print(“<p><form method=”post” action=””>
<table border=”0″ cellpadding=”10″ cellspacing=”0″>
<tr>
<td align=”left” width=”33%”>
<b>Title of comic:</b><br>
<input type=”text” name=”comicTitle” value=”$comicTitle” style=”background-color: $colorBackground; font-size: 10

pt; font-family: tahoma; color: $colorText;”></input>
</td>
<td align=”center” width=”33%”>
<b>Password:</b><br>
<input type=”password” name=”comicPassword” style=”background-color: $colorBackground; font-size: 10 pt; font-family:

tahoma; color: $colorText;”></input>
</td>
<td align=”right” width=”33%”>
<input type=”submit” name=”comicTitlePosted” value=”Post It” style=”background-color: $colorBackground; font-size:

10 pt; font-family: tahoma; color: $colorText”></input>
</td>
</tr>
</table>
</form>”);
}
else if( ($comicPassword != null) and ($comicPassword == $myComicPassword) and ($comicTitle !=null) )
print(“<center>Comic title has been posted.</center>”);
}

?>[/code]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@welshMar 08.2006 — this is the chunk that gives the first group.
[code=php] print("
</select>
</td>
<td align="center" width="33%">
<b>Title of post:</b><br>
<input type="text" name="postTitle" value="$postTitle" style="background-color: $colorBackground; font-size: 10 pt;

font-family: tahoma; color: $colorText;"></input>
</td>
<td align="right" width="33%">
<b>Password:</b><br>
<input type="password" name="password" style="background-color: $colorBackground; font-size: 10 pt; font-family:

tahoma; color: $colorText;"></input>
</td>
</tr>
<tr>
<td align="center" colspan="3">
<textarea rows="20" cols="75" name="postText" style="background-color: $colorBackground; color:

$colorText;">$postText</textarea><p>
<input type="submit" name="posted" value="Post It" style="background-color: $colorBackground; font-size: 10 pt;

font-family: tahoma; color: $colorText"></input>
</td>
</tr>
</table>
</form>");
[/code]
Copy linkTweet thisAlerts:
@ulyssesdracoauthorMar 08.2006 — So then I just delete that?
Copy linkTweet thisAlerts:
@ulyssesdracoauthorMar 08.2006 — Update:

I removed the code for the first box and tried it. All I get is a blank page. No errors though.

Update 2:

Got it to work through trial and error. Welsh pointed me in the right direction. I ended up deleting more than half of the code. Many thanks.
×

Success!

Help @ulyssesdraco spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...