Jump to content

Recommended Posts

I have this code...

 

 

 

 

 

<form method=post name=adauga_etapa>
<table cellspacing=1 cellpadding=2 border=1 align=center>
<tr><td align=center> .:: Gazde ::. </td> <td align=center> .:: Oaspeti ::. </td></tr>
<tr><td>
              
                <select name="gazde">
                <option value="0">#</option>
                 <?php 
                 $luna=array(2 => "Timisoara", 3 => "Otelu", 4 => "Fc Vaslui", 5 => "Rapid", 6 => "Dinamo", 7 => "Steaua", 8 => "Gaz Metan", 9 => "CFR Cluj", 10 => "Targu Mures", 11 => "U Cluj", 12 => "Astra", 13 => "Brasov", 14 => "Pandurii Tg. Jiu", 15 => "Gloria Bistrita", 16 => "Craiova", 17 => "Urziceni" , 18 => "Victoria Branesti" , 19 => "Sportul");
                  foreach ($luna as $k => $v)
                  echo "<option value=$v>$v</option>"; 
                 ?>
                </select> </td> <td>



                <select name="oaspeti">
                <option value="0">#</option>
                 <?php 
                 $luna=array(2 => "Timisoara", 3 => "Otelu", 4 => "Fc Vaslui", 5 => "Rapid", 6 => "Dinamo", 7 => "Steaua", 8 => "Gaz Metan", 9 => "CFR Cluj", 10 => "Targu Mures", 11 => "U Cluj", 12 => "Astra", 13 => "Brasov", 14 => "Pandurii Tg. Jiu", 15 => "Gloria Bistrita", 16 => "Craiova", 17 => "Urziceni" , 18 => "Victoria Branesti" , 19 => "Sportul");
                  foreach ($luna as $k => $v)
                  echo "<option value=$v>$v</option>"; 
                 ?>
                </select> </td></tr>
<tr><td colspan=2 align=center><input type=submit name=adauga value=Adauga /></td></tr>				</table>


</form>



<?php
if (isset($_POST['adauga']))
{

echo $_POST['gazde']." - ".$_POST['oaspeti'];

}
?>

 

 

When i submit a string like (FC Vaslui, Gaz Metan or CFR Cluj ), a string created from two words  it only appeat the first part of the word...

What could i do that, when i pres submit button full sting should appear?

Im at the very begining in this language and a little help will be apreciated :) .. thanks

Link to comment
https://forums.phpfreaks.com/topic/236114-have-this-code/
Share on other sites

firstly, get into the habit of placing your attributes in double quotations, example

these lines

<form method=post name=adauga_etapa>
<table cellspacing=1 cellpadding=2 border=1 align=center>

should be

<form method="post" name="adauga_etapa">
<table cellspacing="1" cellpadding="2" border="1" align="center">

this will help you to avoid errors in the future...

also, can you show me an example of what this line

echo $_POST['gazde']." - ".$_POST['oaspeti'];

is echoing when the form is submitted with 2 word strings.

 

Link to comment
https://forums.phpfreaks.com/topic/236114-have-this-code/#findComment-1213865
Share on other sites

Try the following code, I've add any double and signle quotes where necessary.

 

<form method="POST" action="" name="adauga_etapa">
  <table cellspacing="1" cellpadding="2" border="1" align="center">
    <tr>
      <td align="center"> .:: Gazde ::. </td>
      <td align="center"> .:: Oaspeti ::. </td>
    </tr>
    <tr>
      <td>
        <select name="gazde">
          <option value="0">#</option>
  <?php 
    $luna=array(1 => "Timisoara", "Otelu", "Fc Vaslui", "Rapid", "Dinamo", "Steaua", "Gaz Metan", "CFR Cluj", "Targu Mures", "U Cluj", "Astra", "Brasov", "Pandurii Tg. Jiu", "Gloria Bistrita", "Craiova", "Urziceni", "Victoria Branesti", "Sportul");
    foreach ($luna as $k => $v) {
      echo "<option value='$v'>$v</option>"; 
    }
  ?>
        </select> 
      </td>
      <td>
        <select name="oaspeti">
          <option value="0">#</option>
  <?php 
    foreach ($luna as $k => $v) {
      echo "<option value='$v'>$v</option>"; 
    }
  ?>
        </select>
      </td>
    </tr>
    <tr>
      <td colspan="2" align="center"><input type="submit" name="adauga" value="Adauga" /></td>
    </tr>
  </table>
</form>

<?php
if (isset($_POST['adauga']))
{

echo $_POST['gazde']." - ".$_POST['oaspeti'];

}
?>

 

Try it out and tell me how it goes :)

 

Regards, PaulRyan.

Link to comment
https://forums.phpfreaks.com/topic/236114-have-this-code/#findComment-1213872
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.