Mordax Praetorian Posted January 3, 2008 Share Posted January 3, 2008 I have a form outputting to the following script: newspost.php <HTML> <BODY> <?php $user = $_POST('user'); $title = $_POST('title'); $content = nl2br(htmlentities($_POST('content'))); $pass = md5($_POST('pass')); echo "lookit! something works"; if ($user = 'no') { $fail = 1; echo "<BR>No User Selected"; } if ($title = '') { $fail = 1; echo "<BR>No Title Given"; } if ($content = '') { $fail = 1; echo "<BR>Nothing to Post"; } if ($pass != '66e6422bfdd2afd36400fbb0d57f104a') { $fail = 1; echo "<BR>Incorrect Password"; } if ($fail != 1) { $main = file_get_contents('main.html'); list($before, $after) = explode('<B>Latest News:</B><P>', $main); if ($user = 'dax') { $username = 'Mordax Praetorian'; $back = 'grey'; $pic = 'dax.png'; } if ($user = 'emsem') { $username = 'Emsem Danceaholic'; $back = 'orange'; $pic = 'emsem.png'; } if ($user = 'abseh') { $username = 'Abseh<sup>TM</sup>'; $back = 'purp'; $pic = 'abseh.png'; } if ($user = 'j') { $username = 'Jonathan'; $back = 'cyan'; $pic = 'j.jpg'; } $almost = array($before, "<B>Latest News:</B><P>/n/r<TABLE WIDTH=100%><TR><TD BACKGROUND='images/", $back, ".png' WIDTH='100'><IMG SRC='images", $pic, "></TD><TD BACKGROUND='images/", $back, ".png' WIDTH=20%>", $username, "</TD><TD BACKGROUND='images/", $back, ".png'><B>", $title, "</B></TD><TD BACKGROUND='images/", $back, ".png' WIDTH=10%>", date(jS M Y), "</TD></TR></TABLE><BR>", $content, "<P>/n/r", $after); $there = implode("", $almost); $file = fopen('main.html',wt); fwrite($file, $there); fclose($file); } ?> </BODY> </HTML> The problem is that no matter what information is passed to the script through the form, it does nothing I get a blank page, and main.html remains unaltered What really gets me, is that even the first echo command doesn't work whats wrong with my code? Quote Link to comment https://forums.phpfreaks.com/topic/84212-solved-making-newsposts/ Share on other sites More sharing options...
neilfurry Posted January 3, 2008 Share Posted January 3, 2008 it seems that your using the $_POST super globals the wrong way. $user = $_POST('user'); $title = $_POST('title'); $content = nl2br(htmlentities($_POST('content'))); $pass = md5($_POST('pass')); try changing all the $_post() to $_POST['var'] ex: $_POST['user']; Quote Link to comment https://forums.phpfreaks.com/topic/84212-solved-making-newsposts/#findComment-428833 Share on other sites More sharing options...
Mordax Praetorian Posted January 3, 2008 Author Share Posted January 3, 2008 Ok, made that change, the page still doesn't do anything Quote Link to comment https://forums.phpfreaks.com/topic/84212-solved-making-newsposts/#findComment-428835 Share on other sites More sharing options...
Northern Flame Posted January 3, 2008 Share Posted January 3, 2008 are you sure main.html is writeable? Quote Link to comment https://forums.phpfreaks.com/topic/84212-solved-making-newsposts/#findComment-428840 Share on other sites More sharing options...
Mordax Praetorian Posted January 3, 2008 Author Share Posted January 3, 2008 yep, I made another script just to check that, uploaded it and ran it once Quote Link to comment https://forums.phpfreaks.com/topic/84212-solved-making-newsposts/#findComment-428847 Share on other sites More sharing options...
Mordax Praetorian Posted January 3, 2008 Author Share Posted January 3, 2008 Ok, I started running the script in bits to see where the problem was I got this far: <HTML> <BODY> <?php $user = $_POST['user']; $title = $_POST['title']; $content = nl2br(htmlentities($_POST['content'])); $pass = md5($_POST['pass']); echo $user; if ($user = "no") { $fail = 1; echo "<BR>No User Selected"; } ?> </BODY> </HTML> The code does output, which is good, however the If command does not work When I change which user is outputted by the form, the first echo command changes to match, however the contents of the IF command run weather the user is "no" or otherwise what is going on? Quote Link to comment https://forums.phpfreaks.com/topic/84212-solved-making-newsposts/#findComment-428987 Share on other sites More sharing options...
kenrbnsn Posted January 3, 2008 Share Posted January 3, 2008 Two "==" are used for comparison. One "=" is used for assignment. Ken Quote Link to comment https://forums.phpfreaks.com/topic/84212-solved-making-newsposts/#findComment-428988 Share on other sites More sharing options...
Mordax Praetorian Posted January 3, 2008 Author Share Posted January 3, 2008 thanks, that fixed that one by process of elimination, I have determined that this line: $almost = array($before, "<B>Latest News:</B><P>/n/r<TABLE WIDTH=100%><TR><TD BACKGROUND='images/", $back, ".png' WIDTH='100'><IMG SRC='images", $pic, "></TD><TD BACKGROUND='images/", $back, ".png' WIDTH=20%>", $username, "</TD><TD BACKGROUND='images/", $back, ".png'><B>", $title, "</B></TD><TD BACKGROUND='images/", $back, ".png' WIDTH=10%>", date(jS M Y), "</TD></TR></TABLE><BR>", $content, "<P>/n/r", $after); Is the reason for the blank screen problem... should have seen that one comming really Guess I'll read up on array functions and then go about this in a more convoluted method Quote Link to comment https://forums.phpfreaks.com/topic/84212-solved-making-newsposts/#findComment-429006 Share on other sites More sharing options...
kenrbnsn Posted January 3, 2008 Share Posted January 3, 2008 Your problem is date(jS M Y) needs the argument quoted date('jS M Y') But I'm really not sure what you're trying to do with this array. Ken Quote Link to comment https://forums.phpfreaks.com/topic/84212-solved-making-newsposts/#findComment-429017 Share on other sites More sharing options...
Mordax Praetorian Posted January 3, 2008 Author Share Posted January 3, 2008 HELL YES!! I have a working programme Thannkyou, all of you The idea is to put all the peices of the webpage into an array and then implode() them all into a string I know theres probably a function for linking strings together somewhere, but I have no clue how to do it in any case, the programme works, and I will be giving these forums some serious credit when I get around to making that part of the site thankyou again Quote Link to comment https://forums.phpfreaks.com/topic/84212-solved-making-newsposts/#findComment-429026 Share on other sites More sharing options...
kenrbnsn Posted January 3, 2008 Share Posted January 3, 2008 To concatenate strings you use the "." operator. In your case: <?php $almost = $before . "<B>Latest News:</B><P>\r\n<TABLE WIDTH=100%><TR><TD BACKGROUND='images/" . $back . ".png' WIDTH='100'><IMG SRC='images" . $pic . "></TD><TD BACKGROUND='images/" . $back . ".png' WIDTH=20%>" . $username, "</TD><TD BACKGROUND='images/" . $back . ".png'><B>" . $title . "</B></TD><TD BACKGROUND='images/" . $back . ".png' WIDTH=10%>" . date(jS M Y) . "</TD></TR></TABLE><BR>" . $content . "<P>\r\n" . $after; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/84212-solved-making-newsposts/#findComment-429213 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.