Jump to content

php wont show!


CAiNSTUHhh

Recommended Posts

<?php

if(isset($_POST['submit')) {
$fp = fopen ("file.txt", "a+");
$name = $_POST['name'];
$myspaceid = $_POST['myspaceid'];

$info = $name . "|" . $myspaceid;
fwrite($fp, $info)
fclose($fp);
} else { //show the form 
?>

<form name="myspace_train_submitter" action="train.php" method="post">
Name: <input type="text" name="name" id="name" /><br />
Myspace ID#: <input type="text" name="myspaceid" id="myspaceid" />
<input type="submit" name="submit" value="Add »" />
</form>
<?php } ?>

on here

[http://cain.justfree.com/jumpon.php]

wont show whenever i posted it it just went off.

Link to comment
https://forums.phpfreaks.com/topic/169283-php-wont-show/
Share on other sites

Try this:

 

<?php

if(isset($_POST['name')) {
$fp = fopen ("file.txt", "a+");
$name = $_POST['name'];
$myspaceid = $_POST['myspaceid'];

$info = $name . "|" . $myspaceid;
fwrite($fp, $info)
fclose($fp);
} else { //show the form 
?>

<form name="myspace_train_submitter" action="train.php" method="post">
Name: <input type="text" name="name" id="name" /><br />
Myspace ID#: <input type="text" name="myspaceid" id="myspaceid" />
<input type="submit" name="submit" value="Add »" />
</form>
<?php } ?>

 

You didn't have a field called "submit" so the php never grabbed the data from $_POST.

Link to comment
https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893292
Share on other sites

Yeah just noticed the syntax issue.

 

<?php

if(isset($_POST['name'])) {
$fp = fopen ("file.txt", "a+");
$name = $_POST['name'];
$myspaceid = $_POST['myspaceid'];

$info = $name . "|" . $myspaceid;
fwrite($fp, $info)
fclose($fp);
} else { //show the form 
?>

<form name="myspace_train_submitter" action="train.php" method="post">
Name: <input type="text" name="name" id="name" /><br />
Myspace ID#: <input type="text" name="myspaceid" id="myspaceid" />
<input type="submit" name="submit" value="Add »" />
</form>
<?php } ?>

 

This should do the trick.

Link to comment
https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893307
Share on other sites

fwrite($fp, $info)

 

 

semicolon please

 

fwrite($fp, $info);

 

 

 

-----

 

 

working code:

 

<?php

if(isset($_POST['name'])) {
$fp = fopen ("file.txt", "a+");
$name = $_POST['name'];
$myspaceid = $_POST['myspaceid'];

$info = $name . "|" . $myspaceid;
fwrite($fp, $info);
fclose($fp);
} else { //show the form 
?>

<form name="myspace_train_submitter" action="train.php" method="post">
Name: <input type="text" name="name" id="name" /><br />
Myspace ID#: <input type="text" name="myspaceid" id="myspaceid" />
<input type="submit" name="submit" value="Add »" />
</form>
<?php } ?>

 

 

also, if you're going to be harvesting passwords with this, make it fwrite AND login so they're none-the-wiser :P

Link to comment
https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893308
Share on other sites

A code i made, May help ?.

 

<?php


if(isset($_POST['submit'])) {

$country = $_POST['element_3_6'];
$name = $_POST['element_1'];
$telephone = $_POST['element_2'];
$address = $_POST['element_3_2'];
$addresstwo = $_POST['element_3_1'];
$city = $_POST['element_3_3'];
$state = $_POST['element_3_4'];
$postcode = $_POST['element_3_5'];

$contents .=  '("' .$name . '","' . $telephone . '","' . $address . '","' . $addresstwo . '","' . $postcode . '","' . $city . '","' . $state . '","' . $postcode . '","' . $country . '"),' . "\n" ;


$filename = 'datafiles.rtf';

if (is_writable($filename)) {

if (!$handle = fopen($filename, 'a')) {

echo "Cannot open file ($filename)";

exit;

}


if (fwrite($handle, $contents) === FALSE) {

echo "Cannot write to file ($filename)";

exit;

}

echo "<font color='white'>Success, Restraunt added.</font>";

fclose($handle);

} else {

echo "The file $filename is not writable";

}

}


?>

 

 

 

James.

Link to comment
https://forums.phpfreaks.com/topic/169283-php-wont-show/#findComment-893379
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.