Jump to content

Recommended Posts

I was curious if there was something like "preg_delete" in php... Here is my code where I would like to use something like that:

[code]
foreach ($_POST as $question => $answer)
     {
           $question = preg_replace('/_/', ' ', $question);
         $question = preg_replace('/submit/', '', $question);
           $answer = preg_replace('/Post this survey on your Myspace!/', '', $answer);
               {
                echo ("<li><b>" . $question . "</b><br>" . $answer . "</li>");
               }
     }
[/code]

Basically instead of saying:

[code]
$question = preg_replace('/submit/', '', $question);
$answer = preg_replace('/Post this survey on your Myspace!/', '', $answer);
[/code]

I would like to have something that when $question = submit and $answer = post this survey on your myspace, it doesn't echo that variable. I suppost this could work with a if/else statement... But I am really new to php and don't quite understand the ins and outs of coding such a statement. If anyone could help, that would be grand.
Link to comment
https://forums.phpfreaks.com/topic/12275-preg_delete/
Share on other sites

If you're new to PHP you shouldn't really be messing around with regular expressions unless you have experience with them. str_replace() will do your job fine. But that's not what you want to use. What you want is (if I understand correctly):
[code]foreach ($_POST as $question => $answer)
{
$question = str_replace('_', ' ', $question);
if($question == 'submit' || $answer == 'Post this survey on your Myspace!')
{
continue;
}
echo ("<li><b>" . $question . "</b><br>" . $answer . "</li>");
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/12275-preg_delete/#findComment-46873
Share on other sites

Wow... That works absolutly perfectly. Thank you so much. I realized that I shouldn't be messing around with those... But really, I have taught myself what I know about php in the last few days simply from reading message boards and php sites and referencing other scripts... So I dont really know what I know. All I know is so far I have built an entire backend php system for posting quizzes automatically onto your myspace. I am a tad proud of that. Haha.

Now, I have another question for you... It may have less to do with php... But I am not sure. I have a file called "submit.php" (the code you helped me on is part of this file) which basically takes all the questions and answers the user submits and generates a html coded script to be then submitted to myspace's bulletin page. As it stands the user has to press submit on the submit page to send it to myspace. Is there a way for php to automatically send the contents of a textbox (the html form element) via POST to myspace? Here is the code from the submit page:

[code]
<?php include 'header.php'; ?>
    <div class="vertspace"> </div>
        <div class="alert"><br>Your quiz has been created!  Press SUBMIT NOW! to send it to your myspace!!<br><br>
        <small><font color="#ff0019"><a title="Log Into Myspace" href="http://login.myspace.com/index.cfm?fuseaction=login" target="_blank">-you must be logged in before you press "submit now"-</a></font></small></div>
        <div align="center"><form name="bulletinForm" method="post" target="_self" action="http://bulletin.myspace.com/index.cfm?fuseaction=bulletin.edit"><input type="hidden" value="0" name="groupID">
        <input class="htmlgenscom" type="hidden" maxLength="50" size="1" value="The Greatest Survey Ever" name="subject"><br>
        <textarea class="htmlgenscom" name="body" type="hidden" rows="1" cols="20">
<?php
        
        echo ('<div style="text-align: center;"><br /><font size="3" style="font-weight: bold; text-decoration: underline; color: rgb(255, 102, 0);"><span style="font-weight: bold; color: rgb(255, 0, 0);">Take This Quiz!</span></font><br /><br />');
        echo ('<font size="2" style="color: rgb(0, 0, 255); font-weight: bold;">Do you want to take the quiz below?<br />Without having to copy and paste it?<br />Just go to <font size="3"><a href="http://www.themyspacequiz.com">themyspacequiz.com</a></font>!<br />Its the best place for Myspace quizzes!</font><br /><br /><br /></div><div align="left"><ol>');

        foreach ($_POST as $question => $answer)
            {
            $question = str_replace('_', ' ', $question);
                if($question == 'submit' || $answer == 'Post this survey on your Myspace!')
                    {
                        continue;
                    }
                echo ("<li><b>" . $question . "</b><br>" . $answer . "</li>");
            }

        echo ('</ol></div><div align="center"><font size="3" style="color: rgb(153, 153, 153);"><b><a href="http://www.themyspacequiz.com">http://www.themyspacequiz.com</a></b></font></div>');
        ?>
<br /><br />
        </textarea><br>
        <?php include 'centerad.php' ?>
        <br><input type="submit" class="submit" value="SUBMIT NOW!" name="submit" target="_blank"></form></div>
        </div>
<?php include 'footer.php'; ?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/12275-preg_delete/#findComment-46876
Share on other sites

I don't actually know, I've never had a reason to do it. There might be someone else that can help you out with that although I don't think it's necessary. The sort of 'middle' page you've got there is a good idea as it allows users to make sure they've got the right questions and answers as well as making sure they're logged in.

Personally, I hate quizes on MySpace, they just clog up the bulletin board and some of them are really stupid. But enough people like them to post thousands every day so well done creating a back end for that with only limited PHP experience.
Link to comment
https://forums.phpfreaks.com/topic/12275-preg_delete/#findComment-46880
Share on other sites

Yea... Me either. I have alot of HTML experience... But I never really did any forms beyond your basic mailing form. Haha.

Yea, I think I will keep it. More spaces for ads. ^_^ I catch on to coding pretty fast cause I have done HTML and worked with different systems (php and otherwise) throughout my life.

Oh hey, I am looking at your soul-scape site and wow... Very nice. Just everything, design, coding... Everything. Haha, your "mmorpg" looks pretty neat cool. You should put a mailing list up so I can subscribe to its progress. ^_^ Or a RSS feed or something. Lol.

Thanks again.
Link to comment
https://forums.phpfreaks.com/topic/12275-preg_delete/#findComment-46883
Share on other sites

Well credit for the design goes to our graphics designer, he's rather amazing. The actual coding's nothing special. The MMORPG's been put on hold while we develop Coconut which is a tool for web developers allowing them to fully generate admin panels for sites they made. The coding for that's insane but it looks damn good with Ajax fading and shaking effects and stuff. But yer I've got big plans for the MMORPG unfortunately the only info you'll get on it is probably in [a href=\"http://soul-scape.com/fyorl/\" target=\"_blank\"]my blog[/a] but I wouldn't recommend reading that as it's overloaded with geekiness and ramblings...
Link to comment
https://forums.phpfreaks.com/topic/12275-preg_delete/#findComment-46887
Share on other sites

I don't know about POSTing something to add into your profile, but I have seen people sending bulletins from pages outside of Myspace. I wouldn't recommend doing that though....I have a feeling Myspace has something in the TOS about doing that...unless of course you have no issue with getting your user's accounts deleted.
Link to comment
https://forums.phpfreaks.com/topic/12275-preg_delete/#findComment-46893
Share on other sites

[!--quoteo(post=385210:date=Jun 17 2006, 09:39 PM:name=robos99)--][div class=\'quotetop\']QUOTE(robos99 @ Jun 17 2006, 09:39 PM) [snapback]385210[/snapback][/div][div class=\'quotemain\'][!--quotec--]
unless of course you have no issue with getting your user's accounts deleted.
[/quote]

Bingo. :) I am mainly doing this to learn more about php. And have some fun screwing with myspace.

And I might change it to just give the person the code so they can copy and paste the code to their myspace.
Link to comment
https://forums.phpfreaks.com/topic/12275-preg_delete/#findComment-46897
Share on other sites

[!--quoteo(post=385214:date=Jun 17 2006, 09:46 PM:name=qbit)--][div class=\'quotetop\']QUOTE(qbit @ Jun 17 2006, 09:46 PM) [snapback]385214[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Bingo. :) I am mainly doing this to learn more about php. And have some fun screwing with myspace.

And I might change it to just give the person the code so they can copy and paste the code to their myspace.
[/quote]
Yer, that seems to be what most MySpace helper apps seem to do.
Link to comment
https://forums.phpfreaks.com/topic/12275-preg_delete/#findComment-46903
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.