Premetto che sono agli inizi con Php e da autodidatta. Sto creando un semplice sito dinamico con le poche conoscenze e pescando qua e la in rete stringhe di codice. Ho creato l’index, header, footer e main.php. In main.php che vi mostro qui sotto, ho aggiunto la stringa <? Print $content ?> per poter richiamare ed integrare in una posizione specifica dell’index ( praticamente una sorta di blocco centrale delimitato da due righe orizzontali ) dei file in html che ho creato e posizionato in una cartella Contenuti.
<?
include("head.php");
head("$title");
?>
<table width="100%">
<tr><td>
<!-- Nav Links -->
<? include("navlinks.php") ?>
</td></tr>
<tr><td width="100%">
<hr size="1" noshade>
<!-- CONTENT goes here -->
<? print $content ?> ß-----------------------------
</td></tr>
<tr><td>
<!-- Footer Goes Here -->
<? include("footer.php") ?>
</td></tr>
</table>
</body>
</html>
Ora finchè si trattava di html tutto bene ma ho pensato di itegrare anche un modulo del tipo servizio clienti sviluppato in php e html ( che ho chiamato service.php visibile quì sotto ) e qui mi sono arenato alla grande.
<?php
if(isset($submit)):
if($type == "comment"):
$file = "comments.html";
elseif($type == "suggestion"):
$file = "suggestions.html";
else:
$file = "complaints.html";
endif;
if(!$open_file = fopen($file, "a")):
print("Error! File can't be opened!");
else:
$date = date("M d, Y");
$comments = "Feedback from $name, $email on $date\n\nTheir Feedback is:\n$feedback\n";
fwrite($open_file,"<pre>$comments</pre><hr>");
fclose($open_file);
$company_to = "[email protected]";
$subject1 = "Feedback from the Website!";
$subject2 = "Thanks for your feedback!";
$body = "Thanks for your recent feedback!\nOur customer Service depertment is looking it over and should get back to you shortly.\n";
$body .= "\n\nCustomer Service Department";
//mail($company_to,$subject1,$comments);
mail($email,$subject2,$body);
?>
<h2>Thanks for your feedback!</h2>
<p>Your feedback has been sent to our customer service department.
<?
endif;
else:
?>
<h2>Contact Us</h2>
<form action="service.php" method="POST">
<input type="radio" name="type" value="comment"> Comment on our Site or our Services
<br><input type="radio" name="type" value="suggestion"> Suggest Improvements
<br><input type="radio" name="type" value="complaint"> File a Complaint with Customer Service
<p>Please Enter Your Feedback:
<br><textarea name="feedback" cols="40" rows="10"></textarea>
<p>Name: <input type="text" name="name">
<br>Email: <input type="text" name="email">
<p><input type="submit" name="submit" value="Submit"><input type="Reset">
</form>
<?
endif;
?>
<?
include("../main.php");
?>
Domanda !!! Come posso accomunare questo codice alla variabile $content per poter visualizzare il modulo nello stesso punto dell’index dove vedo anche i contenuti html sopra citati ? Ho provato con un semplice include ma lo fa vedere in un'altra posizione.
Mi scuso per essermi dilungato, spero di essere stato abbastanza chiaro nella spiegazione. Ringrazio fin d’ora tutti quelli che possono aiutarmi .
Ciao e Grazie !!!
<?
include("head.php");
head("$title");
?>
<table width="100%">
<tr><td>
<!-- Nav Links -->
<? include("navlinks.php") ?>
</td></tr>
<tr><td width="100%">
<hr size="1" noshade>
<!-- CONTENT goes here -->
<? print $content ?> ß-----------------------------
</td></tr>
<tr><td>
<!-- Footer Goes Here -->
<? include("footer.php") ?>
</td></tr>
</table>
</body>
</html>
Ora finchè si trattava di html tutto bene ma ho pensato di itegrare anche un modulo del tipo servizio clienti sviluppato in php e html ( che ho chiamato service.php visibile quì sotto ) e qui mi sono arenato alla grande.
<?php
if(isset($submit)):
if($type == "comment"):
$file = "comments.html";
elseif($type == "suggestion"):
$file = "suggestions.html";
else:
$file = "complaints.html";
endif;
if(!$open_file = fopen($file, "a")):
print("Error! File can't be opened!");
else:
$date = date("M d, Y");
$comments = "Feedback from $name, $email on $date\n\nTheir Feedback is:\n$feedback\n";
fwrite($open_file,"<pre>$comments</pre><hr>");
fclose($open_file);
$company_to = "[email protected]";
$subject1 = "Feedback from the Website!";
$subject2 = "Thanks for your feedback!";
$body = "Thanks for your recent feedback!\nOur customer Service depertment is looking it over and should get back to you shortly.\n";
$body .= "\n\nCustomer Service Department";
//mail($company_to,$subject1,$comments);
mail($email,$subject2,$body);
?>
<h2>Thanks for your feedback!</h2>
<p>Your feedback has been sent to our customer service department.
<?
endif;
else:
?>
<h2>Contact Us</h2>
<form action="service.php" method="POST">
<input type="radio" name="type" value="comment"> Comment on our Site or our Services
<br><input type="radio" name="type" value="suggestion"> Suggest Improvements
<br><input type="radio" name="type" value="complaint"> File a Complaint with Customer Service
<p>Please Enter Your Feedback:
<br><textarea name="feedback" cols="40" rows="10"></textarea>
<p>Name: <input type="text" name="name">
<br>Email: <input type="text" name="email">
<p><input type="submit" name="submit" value="Submit"><input type="Reset">
</form>
<?
endif;
?>
<?
include("../main.php");
?>
Domanda !!! Come posso accomunare questo codice alla variabile $content per poter visualizzare il modulo nello stesso punto dell’index dove vedo anche i contenuti html sopra citati ? Ho provato con un semplice include ma lo fa vedere in un'altra posizione.
Mi scuso per essermi dilungato, spero di essere stato abbastanza chiaro nella spiegazione. Ringrazio fin d’ora tutti quelli che possono aiutarmi .
Ciao e Grazie !!!