problem with form in php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lnxsimon

    problem with form in php

    Hi,
    i have a problem with a form. In my page there is the following code:


    --------------------------------------------------------------------------------

    <script language="javas cript">
    <!--
    function Modulo() {
    // Variabili associate ai campi del modulo
    var news_titolo = document.news.n ewstitolo.value ;
    var news_sottotitol o = document.news.n ewssottotitolo. value;
    var news_contenuto = document.news.n ewscontenuto.va lue;
    var news_autore = document.news.n ewsadmin.value;
    //Effettua il controllo sul campo newstitolo
    if ((news_titolo == "") || (news_titolo == "undefined" )) {
    alert("Inserire il titolo della news");
    document.news.n ewstitolo.focus ();
    return false;
    }
    //Effettua il controllo sul campo newssottotitolo
    else if ((news_sottotit olo == "") || (news_sottotito lo == "undefined" )) {
    alert("Inserire il sottotilo della news");
    document.news.n ewssottotitolo. focus();
    return false;
    }
    //Effettua il controllo sul campo newscontenuto
    else if ((news_contenut o == "") || (news_contenuto == "undefined" )) {
    alert("Inserire il contenuto della news");
    document.news.n ewscontenuto.fo cus();
    return false;
    }
    //Effettua il controllo sul campo newadmin
    else if ((news_autore == 0) || (news_autore == "undefined" )) {
    alert("Inserire l'autore della news");
    document.news.n ewsadmin.focus( );
    return false;
    }

    --------------------------------------------------------------------------------



    it's JavaScript code to check if all fields are compiled. In the beginning of the page i use the following code to check if $Invia exists:



    --------------------------------------------------------------------------------

    if (isset($Invia))
    {
    mysql_query("IN SERT INTO engine_news (news_titolo, news_sottotitol o, news_data, news_ora, news_contenuto, admin_ID) VALUES ('$newstitolo', '$newssottotito lo'," . CURRENT_DATE . "," . CURRENT_TIME .. ",'$newscontenu to','$newsadmin ')");
    }
    else
    {

    --------------------------------------------------------------------------------


    after that the script writes a code for the form.
    I need to give a variable $Invia (the name of the button of the form) through the JavaScript.
    How i can do it?

    Tnx lnxsimon.
  • lnxsimon

    #2
    Re: problem with form in php

    I'm glad, I've solved it.

    lnx simone.
    "lnxsimon" <fornarasimone@ tin.it> ha scritto nel messaggio news:T1TMa.1351 8$HU3.417213@ne ws2.tin.it...
    Hi,
    i have a problem with a form. In my page there is the following code:


    ------------------------------------------------------------------------------

    <script language="javas cript">
    <!--
    function Modulo() {
    // Variabili associate ai campi del modulo
    var news_titolo = document.news.n ewstitolo.value ;
    var news_sottotitol o = document.news.n ewssottotitolo. value;
    var news_contenuto = document.news.n ewscontenuto.va lue;
    var news_autore = document.news.n ewsadmin.value;
    //Effettua il controllo sul campo newstitolo
    if ((news_titolo == "") || (news_titolo == "undefined" )) {
    alert("Inserire il titolo della news");
    document.news.n ewstitolo.focus ();
    return false;
    }
    //Effettua il controllo sul campo newssottotitolo
    else if ((news_sottotit olo == "") || (news_sottotito lo == "undefined" )) {
    alert("Inserire il sottotilo della news");
    document.news.n ewssottotitolo. focus();
    return false;
    }
    //Effettua il controllo sul campo newscontenuto
    else if ((news_contenut o == "") || (news_contenuto == "undefined" )) {
    alert("Inserire il contenuto della news");
    document.news.n ewscontenuto.fo cus();
    return false;
    }
    //Effettua il controllo sul campo newadmin
    else if ((news_autore == 0) || (news_autore == "undefined" )) {
    alert("Inserire l'autore della news");
    document.news.n ewsadmin.focus( );
    return false;
    }

    ------------------------------------------------------------------------------



    it's JavaScript code to check if all fields are compiled. In the beginning of the page i use the following code to check if $Invia exists:



    ------------------------------------------------------------------------------

    if (isset($Invia))
    {
    mysql_query("IN SERT INTO engine_news (news_titolo, news_sottotitol o, news_data, news_ora, news_contenuto, admin_ID) VALUES ('$newstitolo', '$newssottotito lo'," . CURRENT_DATE . "," . CURRENT_TIME .. ",'$newscontenu to','$newsadmin ')");
    }
    else
    {

    ------------------------------------------------------------------------------


    after that the script writes a code for the form.
    I need to give a variable $Invia (the name of the button of the form) through the JavaScript.
    How i can do it?

    Tnx lnxsimon.

    Comment

    Working...