Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Function help

  1. #1
    Regular Coder
    Join Date
    Dec 2004
    Thanked 0 Times in 0 Posts

    Function help

    Ok a while back i asked for some help with functions and i though i got what i wanted done but for some strange reason it wont. What i want done is for right before the html in the script i am about to show is to have two functions. One of them looks for '/nickchange' at the beging of the post and if they have that it will change the cookie called 'name' to what is after '/nickchange'. The other one i want to look for '/me' at the beging write to the file with the html coding that is turn just the line it added purple. But the hard part is that i don't want it to add to the file '/nickchange bob' for example when it is done with the functions. Here is the script if there is any questions please ask me
    <body align='center'>
    <iframe src='filer.php' width='95%' height='85%' name="as">
    <table width='95%'>
    <td align='center' width='100%'>
    <form action='chat.php' method='post' name='m'>
    Message : <input name='msg' size=60><input type='submit' name='send' value='Send'>
    $msg3 = $_POST["msg"];
    $file = "file.txt";
    $msg2 = $name . ":" . $msg3 . "\n";
    $msg1 = str_replace("<", " &lt; ", "$msg2");
    $msg = str_replace(">", " &gt; ", "$msg1");
    $fp = fopen ($file, 'a+');
    fwrite ($fp, $msg2);
    fclose ($fp);
    Echo "Please Input a Message";

  • #2
    Senior Coder
    Join Date
    Aug 2003
    One step ahead of you.
    Thanked 3 Times in 3 Posts
    The simplest way to do such things:
    PHP Code:
    '/nickchange n00b';
    substr($input04) == '/me ')
    'ME: ' substr($input4);
    substr($input012) == '/nickchange ')
    'I changed my nick to: ' substr($input12);
    I'm not sure if this was any help, but I hope it didn't make you stupider.

    Experience is something you get just after you really need it.
    PHP Installation Guide Feedback welcome.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts