Jump to content
xisto Community

HannahI

Members
  • Content Count

    351
  • Joined

  • Last visited

Posts posted by HannahI


  1. I have a script that goes to a social networking site that I am creating. I am having some difficultys using this script to post data on the users page for others to see the users thoughts. Just in case you need more information, I have plenty more in log files I write to in the script. I hope you can help me get the script working. By the way, don't blame me because I'm not using MySQL because you won't get me to switch.

    <?php// Initsession_start();if(!session_is_registered(myusername)){		 header("Location:mainlogin.php?		 next=post.php");}// Declare Variables and Arrays$months = array("Jan-","Feb-","Mar-","Apr-","May-","Jun-","Jul-","Aug-","Sep-","Oct-","Nov-","Dec-");$days = array("Sun-","Mon-","Tue-","Wed-","Thu-","Fri-","Sat-");$years = array(2010);$page = $_SESSION['username'].'.html';// Generate Past Post Data		 $current = str_replace("<html><head><link rel='stylesheet' href='style.css'></link><title>".$_SESSION['username']."</title><body><img src='logo.gif' width=235 height=95 /><br />".$_SESSION['username']."'s Page <br />","",$page);$current = str_replace("<form action='comment.php' method='get'><input type='hidden' name='current' value='I am getting hungry! Time for dinner.'><input type='hidden' name='page' value='".$_SESSION['username'].".html'>`<input type='text' name='new'><input type='submit' value='Comment'></form><span style='font-style:italic;'>Last Updated on ","",$current);$current = str_replace($months,"",$current);$current = str_replace($days,"",$current);$current = str_replace($years,"",$current);$current = str_replace("</span></body></html>","",$current);// Create a new file$fileUp = file_get_contents($page);$new = $current.'<br />'."<span style='color:".$_POST['importantColor']."'>".$_POST['new']."</span>";$fileDown = str_replace($current,$new,$fileUp);echo $new;// Write to log$log = fopen("friendbooklog.txt","wb");fwrite($log,"Old: \n".$fileUp."\n"."New: \n".$current);fclose($log);// If required, update pageif($_POST['go'] == 1) {$fp = fopen($page,'w+') or die("dead");fwrite($fp,$fileDown);fclose($fp);header("Location: $page");}// Debug?><!-- Form Data --!><html><head><title>Post Content on <?php echo $_SESSION['username']; ?><link rel="stylesheet" href="style.css"></link></head><body><img id="logo" src="logo.gif" width="234" height="95"> <br />Hello, <? echo $_SESSION['username']; ?><form action="?" method="post"><input type="hidden" name="go" value="1"><textarea rows="10" cols=30" name="new">Put Content Here</textarea> <br />This is<input type="radio" name="importantColor" value="#990000">Important<input type="radio" name="importantColor" value="#000000">Not important <br /><input type="hidden" name="page" value="<?php $_SESSION['username'].'.html'; ?>"><input tupe=<input type="submit" value="Post"></form></body></html>


  2. Pii is correct. I will now show you how to create one without mysql though.

    <html><head></head><body><form action="?" method="post">Command:<input type="text" name="command2"><?phpif(isset($_SESSION['command2']) {echo '<input type="hidden" name="command3" value=".$_SESSION['command2'].">';} else if(isset($_SESSION['command3']) {echo '<input type="hidden" name="command4" value=".$_SESSION['command3'].">';}?><input type="hidden" name="go" value="1"><input type="submit"><?phpif($_POST['go'] == 1) {// begin gameecho $_SESSION['command4'];echo $_SESSION['command3'];echo $_SESSION['command2'];//put game here$_SESSION['command3'] == $_SESSION['command2'];$_SESSION['command4'] == $_SESSION['command3']; }?></form></body></html>
    Hope that helped! :)
    Hannah

  3. I once did a very basic facebook app, but then I was bored. Here, I'll walk you through Facebook Developing.

    1: Get a Facebook Account (of course)

    2: Install the developer application

    3: Click the 'Create an Application' button

    4: Go through the pages and fill out the details

    5: Install the PHP Facebook Library from the Developer app homepage

    6: Get your Application Secret and API Key

    7: Create the Hello World Application:

    <?php

    require_once('/facebook-platform/php/facebook.php'); //Where your Facebook Library is located

     

    $facebook = new Facebook('api key','secret key'); // start

     

    $fb_user = $facebook->require_login(); //get username, else redirect to login

    ?>

    Hello <fb:name uid='<?php echo $fb_user; ?>' useyou='false' possesive='true' />! Welcome to my first application!

    <?php

    echo "<pre>Debug:" . print_r(facebook,true) . "</pre>"; // Just for debugging

    ?>

    That code is not mine, don't give me credits.

    8:Expand on to what you already know, create your dream application

    That is all I know. I don't care in learning the API, so don't expect anything more than what I just said to you about the Facebook PHP API. The Facebook API can be in any type of file, even Flash. But you know, Flash probally requires you to use Flex with it to intergrate the Facebook API with Flash. I hope that you learned something from this post, so goodbye! :)

    Hannah


  4. Now that I'm finally back on the net, I wanna say 8ennet helped. I've also added md5 for protection. But now that I have a register script and a login script, I want to be able to have some php code that will say "Hello, FirstName".
    If you need it, this is the sql for the table:

    CREATE TABLE `accounts` (  `username` varchar(50) NOT NULL,  `password` varchar(50) NOT NULL,  `email` varchar(100) NOT NULL,  `level` varchar(50) NOT NULL,  `fname` varchar(50) NOT NULL,  `lname` varchar(50) NOT NULL,  `friends` mediumtext NOT NULL) ENGINE=MyISAM DEFAULT CHARSET=latin1;
    The code up there is really just from the export command, so I'm not sure if it will help you find a solution for the new problem of displaying a greeting. When the script loads I will have the username. Since I have the username, you just need to provide this:
    function displayGreating($name) {// code goes here......}
    Hope you can help me,
    Hannah

  5. Still, no use.
    P.S. This is the current code:

    <?php$link = mysql_connect('localhost:8889','root','root');if(!$link) {die('Error, Whoops: ' . mysql_error());}mysql_real_escape_string($_POST['username']);mysql_real_escape_string($_POST['password']);mysql_real_escape_string($_POST['email']);$sql = "INSERT INTO `accounts`.`info` (`username`, `password`, `email`, `level`) VALUES ('". $_POST['username'] . "', '". $_POST['password'] . "', '" . $_POST['email'] . "','1');";echo $sql;if(!$sql) {die('Error');}mysql_close($link);?>


  6. I get errors when I execute the following script:

    <?php$link = mysql_connect('localhost','root','root');if(!$link) {die('Error, Whoops: ' . mysql_error());}$sql = "INSERT INTO `accounts`.`info` (`username`, `password`, `email`, `level`) VALUES (\". $_POST['username'] . "\, \". $_POST['password'] . "\', \" . $_POST['email'] . "\', \'1');";echo $sql;if(!$sql) {die('Error');}mysql_close($link);?>


  7. I am writing I script to generate RTF files. But the problem is that as soon as I hit the open button, my texteditor occurs an error. Can someone please fix my code?
    Here it is:

    <div class="page" style="background:white;"> <form action="?" method="post"> <select name="font"> <option value="Arial">Arial</option> <option value="Times">Times New Roman</option> </select> <br /> <textarea name="text"> Type Here </textarea> <input type="hidden" name="done" value="1"> <br/> <input type="submit"> </form> <?php $text = ' {\rtf\ansi\ansicpg\1252\cocoartf1038\cocoasubrtf250 {\fontb1\f0\fswiss\fcharset() '.$_POST['font'].';} {\colorb1;\red255\green255\blue255;} \margl440\margl440\vieww9000\veiwh8400\viewkind() \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6489\tx7200\tx7920\tx8640\ql\qnatural\pardirnatutal \f0\fs24 \cf() '.$_POST['text'].' } '; if($_POST['done'] == 1) { $fp = fopen('writetest.rtf','w+'); fwrite($fp,$text); fclose($fp); echo '<a href="writetest.rtf">Download</a>'; } ?> </div>
    Thanks,
    -Hannah
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.