- Home
- Categorie
- Coding e Sistemistica
- PHP
- Alert per form php
-
Ciao alver,
credo tu stai guardando una parte di codice errata.
Quello è solo il modulo in cui il visitatore inserisce i dati.
Per escludere dei risultati, ed altre modifiche di questo genere dovresti modificare il file che elabora i dati ricevuti dal modulo.
-
Questo e' il codice:
function show_search_form($select = 'filename') {
global $grants, $user_status, $font, $bordercolor, $headercolor, $classa,$classb,$backimg, $tablecolor, $mess, $phpExt, $q, $headerfontcolor;echo " <table summary="" border="0" width="950" bgcolor="$bordercolor" cellpadding="4" cellspacing="1">
<tr>
<th align="left" class="$classa" bgcolor="$headercolor" valign="middle">
<font size="2" face="$font" color="$headerfontcolor"><b>$mess[224]</b></font></font>
</th>
</tr>
<td align="left" class="$classb" bgcolor="$tablecolor" valign="middle">
<font size="1" color="$normalfontcolor" face="$font">
<form action="search.${phpExt}?".SID."" method="post" style="margin: 0">
<input type="text" name="q" value="$q" class="vform" size=25> Ricerca Per:
<select name="action" class="vform">";
if($select == 'filename')
echo "
<option value="showsearchresults_byfilename" selected>Cognome</option>
<option value="showsearchresults_byall">Per nome</option>";else echo " <option value=\"showsearchresults_byfilename\">Cognome</option> <option value=\"showsearchresults_byall\" selected>Per nome</option>"; echo " </select> <input class=\"vform\" type=\"submit\" value=\"Cerca\" > </form><br> <table summary=\"\" border=\"0\" width=\"90%\" bgcolor=\"$bordercolor\" cellpadding=\"4\" cellspacing=\"1\"> <font size=\"1\" color=\"$normalfontcolor\" face=\"$font\"> </td> </tr> </table> <br>";
}
devo solo inserire un alert in php,no javascript,possibilmente che se uno fa la ricerca senza inserire neppure una parola ,non viene accettata e appare la scritta inserisci almeno una parola!
tipo questo:
function controllo()
{
if (document.nomeform.nomecampo.value=="")
{
alert("Campo vuoto!")
return(false)
}}
....pero la mia ignoranza non mi permettedi farlo!!
Grazie ancora!!
-
Allora php non centra nulla, il controllo è sempre javascript.
[php]
function show_search_form($select = 'filename') {
global $grants, $user_status, $font, $bordercolor, $headercolor, $classa,$classb,$backimg, $tablecolor, $mess, $phpExt, $q, $headerfontcolor;echo " <table summary=\"\" border=\"0\" width=\"950\" bgcolor=\"$bordercolor\" cellpadding=\"4\" cellspacing=\"1\"> <tr> <th align=\"left\" class=\"$classa\" bgcolor=\"$headercolor\" valign=\"middle\">
<font size="2" face="$font" color="$headerfontcolor"><b>$mess[224]</b></font></font>
</th>
</tr>
<td align="left" class="$classb" bgcolor="$tablecolor" valign="middle">
<font size="1" color="$normalfontcolor" face="$font">
<form action="search.${phpExt}?".SID."" method="post" style="margin: 0">
<input type="text" name="q" value="$q" class="vform" size="25" onblur="if(this.value==""){alert('Inserisci almeno una parola');(this.value='Default';}"> Ricerca Per:
<select name="action" class="vform">";
if($select == 'filename')
echo "
<option value="showsearchresults_byfilename" selected>Cognome</option>
<option value="showsearchresults_byall">Per nome</option>";else echo " <option value=\"showsearchresults_byfilename\">Cognome</option> <option value=\"showsearchresults_byall\" selected>Per nome</option>"; echo " </select> <input class=\"vform\" type=\"submit\" value=\"Cerca\" > </form><br> <table summary=\"\" border=\"0\" width=\"90%\" bgcolor=\"$bordercolor\" cellpadding=\"4\" cellspacing=\"1\"> <font size=\"1\" color=\"$normalfontcolor\" face=\"$font\"> </td> </tr> </table> <br>";
}
[/php]
-
Grazie ,ho provato ma mi da errore !!!
c'e' qualche variante!
-
Ho scordato 2 blackslash, prova cosi:
[php]
function show_search_form($select = 'filename') {
global $grants, $user_status, $font, $bordercolor, $headercolor, $classa,$classb,$backimg, $tablecolor, $mess, $phpExt, $q, $headerfontcolor;echo " <table summary=\"\" border=\"0\" width=\"950\" bgcolor=\"$bordercolor\" cellpadding=\"4\" cellspacing=\"1\"> <tr> <th align=\"left\" class=\"$classa\" bgcolor=\"$headercolor\" valign=\"middle\">
<font size="2" face="$font" color="$headerfontcolor"><b>$mess[224]</b></font></font>
</th>
</tr>
<td align="left" class="$classb" bgcolor="$tablecolor" valign="middle">
<font size="1" color="$normalfontcolor" face="$font">
<form action="search.${phpExt}?".SID."" method="post" style="margin: 0">
<input type="text" name="q" value="$q" class="vform" size="25" onblur="if(this.value==""){alert('Inserisci almeno una parola');(this.value='Default';}"> Ricerca Per:
<select name="action" class="vform">";
if($select == 'filename')
echo "
<option value="showsearchresults_byfilename" selected>Cognome</option>
<option value="showsearchresults_byall">Per nome</option>";else echo " <option value=\"showsearchresults_byfilename\">Cognome</option> <option value=\"showsearchresults_byall\" selected>Per nome</option>"; echo " </select> <input class=\"vform\" type=\"submit\" value=\"Cerca\" > </form><br> <table summary=\"\" border=\"0\" width=\"90%\" bgcolor=\"$bordercolor\" cellpadding=\"4\" cellspacing=\"1\"> <font size=\"1\" color=\"$normalfontcolor\" face=\"$font\"> </td> </tr> </table> <br>";
}
[/php]In caso di errori, incollali sempre per intero in modo da poterli individuare facilmente.
-
e' in questa riga qui:*<select name="action" class="vform">"; *
<td align="left" class="$classb" bgcolor="$tablecolor" valign="middle">
<font size="1" color="$normalfontcolor" face="$font">
<form action="search.${phpExt}?".SID."" method="post" style="margin: 0">
<input type="text" name="q" value="$q" class="vform" size="25" onblur="if(this.value==""){alert('Inserisci almeno una parola');(this.value='Default';}"> Ricerca Per:
*<select name="action" class="vform">"; *
if($select == 'filename')
echo "
-
-
Nel copia incolla sono scomparsi 2 backslash...
[php]
function show_search_form($select = 'filename') {
global $grants, $user_status, $font, $bordercolor, $headercolor, $classa,$classb,$backimg, $tablecolor, $mess, $phpExt, $q, $headerfontcolor;echo " <table summary=\"\" border=\"0\" width=\"950\" bgcolor=\"$bordercolor\" cellpadding=\"4\" cellspacing=\"1\"> <tr> <th align=\"left\" class=\"$classa\" bgcolor=\"$headercolor\" valign=\"middle\">
<font size="2" face="$font" color="$headerfontcolor"><b>$mess[224]</b></font></font>
</th>
</tr>
<td align="left" class="$classb" bgcolor="$tablecolor" valign="middle">
<font size="1" color="$normalfontcolor" face="$font">
<form action="search.${phpExt}?".SID."" method="post" style="margin: 0">
<input type="text" name="q" value="$q" class="vform" size="25" onblur="if(this.value==""){alert('Inserisci almeno una parola');(this.value='Default';}"> Ricerca Per:
<select name="action" class="vform">";
if($select == 'filename')
echo "
<option value="showsearchresults_byfilename" selected>Cognome</option>
<option value="showsearchresults_byall">Per nome</option>";else echo " <option value=\"showsearchresults_byfilename\">Cognome</option> <option value=\"showsearchresults_byall\" selected>Per nome</option>"; echo " </select> <input class=\"vform\" type=\"submit\" value=\"Cerca\" > </form><br> <table summary=\"\" border=\"0\" width=\"90%\" bgcolor=\"$bordercolor\" cellpadding=\"4\" cellspacing=\"1\"> <font size=\"1\" color=\"$normalfontcolor\" face=\"$font\"> </td> </tr> </table> <br>";
}
[/php]
-
@alver said:
e' in questa riga qui:*<select name="action" class="vform">"; *
<td align="left" class="$classb" bgcolor="$tablecolor" valign="middle">
<font size="1" color="$normalfontcolor" face="$font">
<form action="search.${phpExt}?".SID."" method="post" style="margin: 0">
<input type="text" name="q" value="$q" class="vform" size="25" onblur="if(this.value==""){alert('Inserisci almeno una parola');(this.value='Default';}"> Ricerca Per:
*<select name="action" class="vform">"; *
if($select == 'filename')
echo "Niente c'e' qualche punto e virgola o slash di troppo!!
Penso!
-
Niente oggi è giornata, devo accoggermi degli " poco a poco.
Forse questa è la volta buona.[php]
function show_search_form($select = 'filename') {
global $grants, $user_status, $font, $bordercolor, $headercolor, $classa,$classb,$backimg, $tablecolor, $mess, $phpExt, $q, $headerfontcolor;echo " <table summary=\"\" border=\"0\" width=\"950\" bgcolor=\"$bordercolor\" cellpadding=\"4\" cellspacing=\"1\"> <tr> <th align=\"left\" class=\"$classa\" bgcolor=\"$headercolor\" valign=\"middle\">
<font size="2" face="$font" color="$headerfontcolor"><b>$mess[224]</b></font></font>
</th>
</tr>
<td align="left" class="$classb" bgcolor="$tablecolor" valign="middle">
<font size="1" color="$normalfontcolor" face="$font">
<form action="search.${phpExt}?".SID."" method="post" style="margin: 0">
<input type="text" name="q" value="$q" class="vform" size="25" onblur="if(this.value==""){alert('Inserisci almeno una parola');(this.value='Default';}"> Ricerca Per:
<select name="action" class="vform">";
if($select == 'filename')
echo "
<option value="showsearchresults_byfilename" selected>Cognome</option>
<option value="showsearchresults_byall">Per nome</option>";else echo " <option value=\"showsearchresults_byfilename\">Cognome</option> <option value=\"showsearchresults_byall\" selected>Per nome</option>"; echo " </select> <input class=\"vform\" type=\"submit\" value=\"Cerca\" > </form><br> <table summary=\"\" border=\"0\" width=\"90%\" bgcolor=\"$bordercolor\" cellpadding=\"4\" cellspacing=\"1\"> <font size=\"1\" color=\"$normalfontcolor\" face=\"$font\"> </td> </tr> </table> <br>";
}
[/php]
-
Adesso non mi da piu l'errore ma non mi da l'allert!!