Jump to content

[SOLVED] Newby help with form


Mike088

Recommended Posts

I wouldn't really recommend diving into classes if you don't know how to do basic form submission.  But regardless, you're going to have to be more specific about how this class generates this list of words, and how the submitted word is supposed to interact.  In other words, you need to write out in plain english what it is you want to happen, before you can go about coding it.  But even then, don't just tell us what you want.  We aren't here to write code for you.  Write out what you want in plain english, break it down step by step, research how to do each step, if you get stuck on actual code, post the code.

Link to comment
Share on other sites

 

quick 1 page example for you.........

 

save the page as example.php try it ......

 

 

 


<center><h3>Please type >>css<< or >>php<< or >>html<<</h3></center>

<br><br>

<?php

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


$words=(trim($_POST['words']));

switch ($words){

case(php);

echo " <center><h1>php is the best!</h1></center>";

break;

case(html);

echo "<center><h1>html is grate fun!</h1></center>";

break;

case(css);

echo"<center><h1>css is so good fun!</h1></center>";

break;

}
}
?>

<center>
<form method="POST" action="<?php $_SEVER['PHP_SELF']?>">
Type a word please
<br>
<input type="text" name="words">
<br><br>
<input type="submit" name="submit" value="post the famous word!"> 
</form>
</center>

 

Link to comment
Share on other sites

Thanks for the replies. I have a basic script as follows:

 

<form action="index.php" method="post">
Enter Your Word: <input type="text" name="word" />
<input type="submit" value="Submit" />
</form>

<?php echo $_POST["word"]; ?>

 

As you can see I have it just outputting the word that was input. I have a PHP class that generates common misspellings from a word (in this case I want it to be the word the user is inputting to my form). I have no idea on how to get the interaction between the input word and the class. The class I am wanting to use is http://web-professor.net/scripts/typo/cTypoGenerator.txt:(

 

Link to comment
Share on other sites

what about the example shown...

Example Usage:
-----------------------------------------------------------
<?php

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

$word =  trim($_POST["word"]); 
$typos = array();
$typos = cTypoGenerator::getAllTypos( $word );

print_r( $typos );


}

?>

 

i have also checked if post submit is set so make sure you add name="submit" to your submit button

 

Link to comment
Share on other sites

should probably add that you will need to include the file with your class in above that snippet of code

 

and instead of using print_r

 

you might want to use something like this to generate a list

 

foreach($typos as $word) {

echo $word . "<br />";

}

Link to comment
Share on other sites

Sorry that class no good for me, I slip with my hands on the keys all the time ill have a constant error lol.......................................................

 

 

add a

<?php include("script_name.php");?>

to the posted below example

 

DONT FORGET THE DONATION PAGE OFF THIS FORUM.........

 

<?php

include("script_name.php");

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

$word =  trim($_POST["word"]); 
$typos = array();
$typos = cTypoGenerator::getAllTypos( $word );

foreach($typos as $word) {

echo $word . "<br />";

}

}

<form action="index.php" method="post">
Enter Your Word: <input type="text" name="word" />
<input type="submit" value="Submit" />
</form>

?>

Link to comment
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.