Search code examples
phphtmldatabasequotes

Update form to edit record in the DB PHP HTML


guys I have a problem with a PHP page.

I'm trying to make a form to update the record of a DB.

I'm displaying the form with an echo but I have some problems with quotes

<? echo'
                        <img src="logo.jpg"> 
                        <fieldset>
                        <input name="aspettogen2" type="text" value="<?php echo $aspettogen;?>">
                        </fieldset>
                        <fieldset>
                            <input name="desc" type="text" maxlength="255">
                        </fieldset>
                        <fieldset>
                            <input name="ragsoc" type="text" maxlength="100">
                        </fieldset>
                        <fieldset>
                            <input name="numcivico"  type="text" maxlength="20">
                        </fieldset>
                        <fieldset>
                            <input name="validita" type="text">
                        </fieldset>
                        <fieldset>
                            <input name="odierna" type="data">
                        </fieldset>
                        <fieldset>
                            <input name="preavviso" type="text">
                        </fieldset>
                        <fieldset>
                            <input name="scadenza" type="text">
                        </fieldset>
                        <fieldset>
                            <input name="presc" type="text" maxlength="255">
                        </fieldset>
                        <fieldset>
                            <input name="freq" type="number">
                        </fieldset>
                        <fieldset>
                            <input name="datacontr" type="text">
                        </fieldset>
                        <fieldset>
                            <input name="proxcontr" type="text">
                        </fieldset>
                        <fieldset>
                            <input name="note" type="text">
                        </fieldset>             
                    </form>
                </div>
            </body>
        </html>';

in the first fieldset value="<?php echo $aspettogen;?"> it appears gray because the quote after the echo turn it into a "comment" and i cant print the value..

how can i solve it?

i've tried to do like this Value="'<?php echo $aspettogen;?'"> but i receive the error Parse error: syntax error, unexpected '?' in /var/..... on line 50


Solution

  • You have wrong syntax in that line. I have made the necessary changes.

    Code:

    <? echo'
                            <img src="logo.jpg"> 
                            <fieldset>
                            <input name="aspettogen2" placeholder="Aspetto Generale" type="text" value="<?php echo $aspettogen;?>">
                            </fieldset>
                            <fieldset>
                                <input name="desc" placeholder="Descrizione" type="text" maxlength="255">
                            </fieldset>
                            <fieldset>
                                <input name="ragsoc" placeholder="Ragione Sociale" type="text" maxlength="100">
                            </fieldset>
                            <fieldset>
                                <input name="numcivico" placeholder="Numero Civico" type="text" maxlength="20">
                            </fieldset>
                            <fieldset>
                                <input name="validita" placeholder="Validita" type="text">
                            </fieldset>
                            <fieldset>
                                <input name="odierna" placeholder="Data" type="data" id="today" readonly >
                            </fieldset>
                            <fieldset>
                                <input name="preavviso" placeholder="Preavviso" type="text">
                            </fieldset>
                            <fieldset>
                                <input name="scadenza" placeholder="Scadenza" type="text">
                            </fieldset>
                            <fieldset>
                                <input name="presc" placeholder="Prescrizioni" type="text" maxlength="255">
                            </fieldset>
                            <fieldset>
                                <input name="freq" placeholder="Frequenza (in giorni)" type="number">
                            </fieldset>
                            <fieldset>
                                <input name="note" placeholder="Note" type="text">
                            </fieldset>             
                            <fieldset>
                                <button name="submit" type="submit" id="contact-submit">Inserisci</button>
                            </fieldset>
                        </form>
                    </div>
                </body>
            </html>';?>