gbv
10-10-2007, 11:33
Ciao a tutti, premetto che sono alle prime armi, avrei bisogno di aiuto per inserire un form in una pagina di controllo (index.php), ho provato a mettere il codice del form (contatto.php) nell posizione indicata (an example of protected page, put your protected code/stuff here.), ma non funziona.
index.php
include ("functions.php");
//if the user is logged in.
if (is_logged_in($user)) {
include ("header.php");
$cookie_read = explode("|", base64_decode($user));
$username = $cookie_read[1];
//put your code here (protected page).
echo "Welcome <b>$username</b>, [ <a href=users.php>Manage Account</a> ] [ <a href=users.php?maa=Logout>Logout</a> ]<br><br>";
echo "<br><br><br>
<h3>an example of protected page, put your protected code/stuff here.</h3>";
include ("footer.php");
include("feedback.php");
//if the user is not logged in, then tell him to login.
}else{
include ("header.php");
//header("Location: users.php"); die();
echo "Welcome visitor, would you like to [ <a href=users.php>Login</a> ] or [ <a href=\"users.php?maa=Register\">Register</a> ]";
//this code will load all registered users
$sql = mysql_query("SELECT * FROM ".$prefix."_users ORDER BY userid DESC");
$num = mysql_num_rows($sql);
echo "<br><br><br><hr size=1>Total registered users ($num): ";
while($row = mysql_fetch_array($sql)){
$userid = $row['userid'];
$username = $row['username'];
$password = $row['password'];
$ipaddress = $row['ipaddress'];
echo " [ $username ]";
}
include ("footer.php");
}
?>
contatto.php
<html>
<head>
<title>PHP Form Mailer - phpFormMailer (easy to use and more secure than many cgi form
mailers)</title>
<link rel="stylesheet" type="text/css" media="all" href="aqua/theme.css" title="Aqua" />
<script type="text/javascript" src="calendar.js"></script>
<script type="text/javascript" src="calendar-it.js"></script>
<script type="text/javascript">
var oldLink = null;
function setActiveStyleSheet(link, title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
if (oldLink) oldLink.style.fontWeight = 'normal';
oldLink = link;
link.style.fontWeight = 'bold';
return false;
}
// This function gets called when the end-user clicks on some date.
function selected(cal, date) {
cal.sel.value = date; // just update the date in the input field.
if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
cal.callCloseHandler();
}
function closeHandler(cal) {
cal.hide(); // hide the calendar
// cal.destroy();
_dynarch_popupCalendar = null;
}
function showCalendar(id, format, showsTime, showsOtherMonths) {
var el = document.getElementById(id);
if (_dynarch_popupCalendar != null) {
// we already have some calendar created
_dynarch_popupCalendar.hide(); // so we hide it first.
} else {
// first-time call, create the calendar.
var cal = new Calendar(1, null, selected, closeHandler);
// uncomment the following line to hide the week numbers
// cal.weekNumbers = false;
if (typeof showsTime == "string") {
cal.showsTime = true;
cal.time24 = (showsTime == "24");
}
if (showsOtherMonths) {
cal.showsOtherMonths = true;
}
_dynarch_popupCalendar = cal; // remember it in the global var
cal.setRange(1900, 2070); // min/max year allowed.
cal.create();
}
_dynarch_popupCalendar.setDateFormat(format); // set the specified date format
_dynarch_popupCalendar.parseDate(el.value); // try to parse the text in field
_dynarch_popupCalendar.sel = el; // inform it what input field we use
_dynarch_popupCalendar.showAtElement(el.nextSibling, "Br"); // show the calendar
return false;
}
var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;
function isDisabled(date) {
var today = new Date();
return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
}
function flatSelected(cal, date) {
var el = document.getElementById("preview");
el.innerHTML = date;
}
function showFlatCalendar() {
var parent = document.getElementById("display");
var cal = new Calendar(0, null, flatSelected);
cal.weekNumbers = false;
cal.setDisabledHandler(isDisabled);
cal.setDateFormat("%A, %B %e");
cal.create(parent);
cal.show();
}
</script>
<style>
BODY{color:#000000; font-size: 16pt; font-family: arial}
.button {background-color: rgb(128,128,128); color:#ffffff; font-size: 8pt;}
.inputc {font-size: 8pt;}
</style>
</head>
</body>
<center><strong>Prenotazionni</strong></center>
<form name="phpformmailer" action="contact.php" align="center" method="post">
<input class="inputc" size="29" name="tipo_pre" value="<? echo $_REQUEST['tipoprenot']; ?>">
<center><table bgcolor="#E87400" cellspacing="2">
<td align="right" ><small>Nome:</small></td>
<td align="left" ><font face="Arial"><input class="inputc" size="29" name="nome"></font></td>
<td align="right" ><small>Cognome:</small></td>
<td align="left"><font face="Arial"><input class="inputc" size="29" name="cognome"></font></td>
</tr>
<tr>
<td align="right" ><small>Indirizzo:</small></td>
<td colspan="3 align="left"><font face="Arial"><input class="inputc" size="60" name="indirizzo"></font></td>
</tr>
<tr>
<td align="right"><small>Periodo dal:</small></td>
<td><input class="inputc" type="text" name="date1" id="sel1" size="15"><input class="inputc" type="reset" value=" ... "onclick="return showCalendar('sel1', '%d/%m/%Y');"> </td>
<td><small>al:</small></td>
<td><input class="inputc" type="text" name="date3" id="sel3" size="15"><input class="inputc"type="reset" value=" ... "onclick="return showCalendar('sel3', '%d/%m/%Y');"> </td>
</tr>
<tr>
<td align="right" ><font color="#000080" size="1">*</font><small> E-mail:</small></td>
<td align="left" ><font face="Arial"><input class="inputc" size="20"
name="email"></font></td>
</tr>
<tr align="middle">
<td align="right" ><font color="#000080" size="1">*</font><small> Conferma E-mail:</small></td>
<td align="left"><font face="Arial"><input class="inputc" size="20"
name="email2"></font></td>
</tr>
<tr>
<td align="right" ><font color="#000080" size="1">*</font><small> Oggetto:</small></td>
<td ><font face="Arial"><input class="inputc" size="29" name="thesubject"></font></td>
</tr>
<tr>
<td align="right" > <p><font color="#000080" size="1">*</font><small> Altre richieste:</small></td>
<td ><textarea style="FONT-SIZE: 10pt" name="themessage" rows="7" cols="20"></textarea></td>
</tr>
<tr>
<td ></td>
<td >
<script language="JavaScript"><!--
function validateForm()
{
var okSoFar=true
with (document.phpformmailer)
{
var foundAt = email.value.indexOf("@",0)
if (nome.value=="" && okSoFar)
{
okSoFar=false
alert("Inserisci il Nome.")
thesubject.focus()
}
if (cognome.value=="" && okSoFar)
{
okSoFar=false
alert("Inserisci il Cognome.")
thesubject.focus()
}
if (foundAt < 1 && okSoFar)
{
okSoFar = false
alert ("Inserisci un indirizzo Email valido.")
email.focus()
}
var e1 = email.value
var e2 = email2.value
if (!(e1==e2) && okSoFar)
{
okSoFar = false
alert ("L'inndirizzo Email inserito non corrisponde . Ridigitare.")
email.focus()
}
if (thesubject.value=="" && okSoFar)
{
okSoFar=false
alert("Inserisci L'oggetto.")
thesubject.focus()
}
if (themessage.value=="" && okSoFar)
{
okSoFar=false
alert("Inserisci la tua richiesta.")
themessage.focus()
}
if (okSoFar==true) submit();
}
}
// --></script><input type="button" class="button"
value="Invia richiesta" name="B1" ONCLICK="javascript:validateForm()"><small> <small>campi obbligatori *</small></small></td>
</tr>
</table>
</center>
</form>
</body>
</html>
dimenticavo... se apro le pagine cosė come sono funzionano
index.php
include ("functions.php");
//if the user is logged in.
if (is_logged_in($user)) {
include ("header.php");
$cookie_read = explode("|", base64_decode($user));
$username = $cookie_read[1];
//put your code here (protected page).
echo "Welcome <b>$username</b>, [ <a href=users.php>Manage Account</a> ] [ <a href=users.php?maa=Logout>Logout</a> ]<br><br>";
echo "<br><br><br>
<h3>an example of protected page, put your protected code/stuff here.</h3>";
include ("footer.php");
include("feedback.php");
//if the user is not logged in, then tell him to login.
}else{
include ("header.php");
//header("Location: users.php"); die();
echo "Welcome visitor, would you like to [ <a href=users.php>Login</a> ] or [ <a href=\"users.php?maa=Register\">Register</a> ]";
//this code will load all registered users
$sql = mysql_query("SELECT * FROM ".$prefix."_users ORDER BY userid DESC");
$num = mysql_num_rows($sql);
echo "<br><br><br><hr size=1>Total registered users ($num): ";
while($row = mysql_fetch_array($sql)){
$userid = $row['userid'];
$username = $row['username'];
$password = $row['password'];
$ipaddress = $row['ipaddress'];
echo " [ $username ]";
}
include ("footer.php");
}
?>
contatto.php
<html>
<head>
<title>PHP Form Mailer - phpFormMailer (easy to use and more secure than many cgi form
mailers)</title>
<link rel="stylesheet" type="text/css" media="all" href="aqua/theme.css" title="Aqua" />
<script type="text/javascript" src="calendar.js"></script>
<script type="text/javascript" src="calendar-it.js"></script>
<script type="text/javascript">
var oldLink = null;
function setActiveStyleSheet(link, title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
if (oldLink) oldLink.style.fontWeight = 'normal';
oldLink = link;
link.style.fontWeight = 'bold';
return false;
}
// This function gets called when the end-user clicks on some date.
function selected(cal, date) {
cal.sel.value = date; // just update the date in the input field.
if (cal.dateClicked && (cal.sel.id == "sel1" || cal.sel.id == "sel3"))
cal.callCloseHandler();
}
function closeHandler(cal) {
cal.hide(); // hide the calendar
// cal.destroy();
_dynarch_popupCalendar = null;
}
function showCalendar(id, format, showsTime, showsOtherMonths) {
var el = document.getElementById(id);
if (_dynarch_popupCalendar != null) {
// we already have some calendar created
_dynarch_popupCalendar.hide(); // so we hide it first.
} else {
// first-time call, create the calendar.
var cal = new Calendar(1, null, selected, closeHandler);
// uncomment the following line to hide the week numbers
// cal.weekNumbers = false;
if (typeof showsTime == "string") {
cal.showsTime = true;
cal.time24 = (showsTime == "24");
}
if (showsOtherMonths) {
cal.showsOtherMonths = true;
}
_dynarch_popupCalendar = cal; // remember it in the global var
cal.setRange(1900, 2070); // min/max year allowed.
cal.create();
}
_dynarch_popupCalendar.setDateFormat(format); // set the specified date format
_dynarch_popupCalendar.parseDate(el.value); // try to parse the text in field
_dynarch_popupCalendar.sel = el; // inform it what input field we use
_dynarch_popupCalendar.showAtElement(el.nextSibling, "Br"); // show the calendar
return false;
}
var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;
function isDisabled(date) {
var today = new Date();
return (Math.abs(date.getTime() - today.getTime()) / DAY) > 10;
}
function flatSelected(cal, date) {
var el = document.getElementById("preview");
el.innerHTML = date;
}
function showFlatCalendar() {
var parent = document.getElementById("display");
var cal = new Calendar(0, null, flatSelected);
cal.weekNumbers = false;
cal.setDisabledHandler(isDisabled);
cal.setDateFormat("%A, %B %e");
cal.create(parent);
cal.show();
}
</script>
<style>
BODY{color:#000000; font-size: 16pt; font-family: arial}
.button {background-color: rgb(128,128,128); color:#ffffff; font-size: 8pt;}
.inputc {font-size: 8pt;}
</style>
</head>
</body>
<center><strong>Prenotazionni</strong></center>
<form name="phpformmailer" action="contact.php" align="center" method="post">
<input class="inputc" size="29" name="tipo_pre" value="<? echo $_REQUEST['tipoprenot']; ?>">
<center><table bgcolor="#E87400" cellspacing="2">
<td align="right" ><small>Nome:</small></td>
<td align="left" ><font face="Arial"><input class="inputc" size="29" name="nome"></font></td>
<td align="right" ><small>Cognome:</small></td>
<td align="left"><font face="Arial"><input class="inputc" size="29" name="cognome"></font></td>
</tr>
<tr>
<td align="right" ><small>Indirizzo:</small></td>
<td colspan="3 align="left"><font face="Arial"><input class="inputc" size="60" name="indirizzo"></font></td>
</tr>
<tr>
<td align="right"><small>Periodo dal:</small></td>
<td><input class="inputc" type="text" name="date1" id="sel1" size="15"><input class="inputc" type="reset" value=" ... "onclick="return showCalendar('sel1', '%d/%m/%Y');"> </td>
<td><small>al:</small></td>
<td><input class="inputc" type="text" name="date3" id="sel3" size="15"><input class="inputc"type="reset" value=" ... "onclick="return showCalendar('sel3', '%d/%m/%Y');"> </td>
</tr>
<tr>
<td align="right" ><font color="#000080" size="1">*</font><small> E-mail:</small></td>
<td align="left" ><font face="Arial"><input class="inputc" size="20"
name="email"></font></td>
</tr>
<tr align="middle">
<td align="right" ><font color="#000080" size="1">*</font><small> Conferma E-mail:</small></td>
<td align="left"><font face="Arial"><input class="inputc" size="20"
name="email2"></font></td>
</tr>
<tr>
<td align="right" ><font color="#000080" size="1">*</font><small> Oggetto:</small></td>
<td ><font face="Arial"><input class="inputc" size="29" name="thesubject"></font></td>
</tr>
<tr>
<td align="right" > <p><font color="#000080" size="1">*</font><small> Altre richieste:</small></td>
<td ><textarea style="FONT-SIZE: 10pt" name="themessage" rows="7" cols="20"></textarea></td>
</tr>
<tr>
<td ></td>
<td >
<script language="JavaScript"><!--
function validateForm()
{
var okSoFar=true
with (document.phpformmailer)
{
var foundAt = email.value.indexOf("@",0)
if (nome.value=="" && okSoFar)
{
okSoFar=false
alert("Inserisci il Nome.")
thesubject.focus()
}
if (cognome.value=="" && okSoFar)
{
okSoFar=false
alert("Inserisci il Cognome.")
thesubject.focus()
}
if (foundAt < 1 && okSoFar)
{
okSoFar = false
alert ("Inserisci un indirizzo Email valido.")
email.focus()
}
var e1 = email.value
var e2 = email2.value
if (!(e1==e2) && okSoFar)
{
okSoFar = false
alert ("L'inndirizzo Email inserito non corrisponde . Ridigitare.")
email.focus()
}
if (thesubject.value=="" && okSoFar)
{
okSoFar=false
alert("Inserisci L'oggetto.")
thesubject.focus()
}
if (themessage.value=="" && okSoFar)
{
okSoFar=false
alert("Inserisci la tua richiesta.")
themessage.focus()
}
if (okSoFar==true) submit();
}
}
// --></script><input type="button" class="button"
value="Invia richiesta" name="B1" ONCLICK="javascript:validateForm()"><small> <small>campi obbligatori *</small></small></td>
</tr>
</table>
</center>
</form>
</body>
</html>
dimenticavo... se apro le pagine cosė come sono funzionano